Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default VBA or Vlookup?

Hi all,

If I have seven categories in Column A and I want to return a reference
number for each category in colum B. is there a VBA module to achieve this or
it is better with Vloop up?

The table looks like this.

Column A Column B
_________ ____________
Office Equip 100
Ops Equip 200
SHE Equip 300
Security Equip 400
It Equip 500
Comms Equip 600
Vehicels Equip 700


any help on this is appreciated

Best regards
hoshyar
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default VBA or Vlookup?

I would use VLOOKUP every time!

e.g =Vlookup("IT Equip", A:B, 2, False)

would return 500

Any good? You can of cause change "It Equip" in above to any cell!


"Hoshyar" wrote:

Hi all,

If I have seven categories in Column A and I want to return a reference
number for each category in colum B. is there a VBA module to achieve this or
it is better with Vloop up?

The table looks like this.

Column A Column B
_________ ____________
Office Equip 100
Ops Equip 200
SHE Equip 300
Security Equip 400
It Equip 500
Comms Equip 600
Vehicels Equip 700


any help on this is appreciated

Best regards
hoshyar

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default VBA or Vlookup?

I'd say use a vlookup. Not only a lot faster, but also more user
friendly.

=VLOOKUP("SHE Equip",A1:B8,2,FALSE)

Cheers,
Peter

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default VBA or Vlookup?

I would suggest this is a job for VLOOKUP. VBA is overkill.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Hoshyar" wrote in message
...
Hi all,

If I have seven categories in Column A and I want to return a reference
number for each category in colum B. is there a VBA module to achieve this

or
it is better with Vloop up?

The table looks like this.

Column A Column B
_________ ____________
Office Equip 100
Ops Equip 200
SHE Equip 300
Security Equip 400
It Equip 500
Comms Equip 600
Vehicels Equip 700


any help on this is appreciated

Best regards
hoshyar



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default VBA or Vlookup?

Hi DeanO and xPete,

many thanks for your prompt answer. however, this is still not working as I
wanted. These categories may appear sevral times in column (A1:A2000). So
the argument will be. in each cell of B1:B2000 I want to see the reference
number specified to its category. Does this formula works? =Vlookup ("IT
Equip","SHE Equip", "Comms Equip", A:B,2,False)

Please advise
Hoshyar

"DeanO" wrote:

I would use VLOOKUP every time!

e.g =Vlookup("IT Equip", A:B, 2, False)

would return 500

Any good? You can of cause change "It Equip" in above to any cell!


"Hoshyar" wrote:

Hi all,

If I have seven categories in Column A and I want to return a reference
number for each category in colum B. is there a VBA module to achieve this or
it is better with Vloop up?

The table looks like this.

Column A Column B
_________ ____________
Office Equip 100
Ops Equip 200
SHE Equip 300
Security Equip 400
It Equip 500
Comms Equip 600
Vehicels Equip 700


any help on this is appreciated

Best regards
hoshyar



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VBA or Vlookup?

Hoshyar,

If I've understood your requirement correctly, it is as follows:

(a) You have a column of data with 0 < rowcount < 2000 or thereabouts

(b) A valid entry in the column must be one of seven category names, as
follows:
1. Office Equip
2. Ops Equip
3. SHE Equip
4. Security Equip
5. It Equip
6. Comms Equip
7. Vehicels Equip

(c) For each row in your column of data, you want to return a
corresponding reference
number, as per the following:
Category Ref
1. Office Equip 100
2. Ops Equip 200
3. SHE Equip 300
4. Security Equip 400
5. It Equip 500
6. Comms Equip 600
7. Vehicels Equip 700

I would do it like this:

1. Copy your column of data to the range A1:An where n is the count of
rows
2. In the range D1:D7, enter the category names
3. In the range E1:E7, enter the corresponding reference numbers
4. Sort the range D1:E7 on "Column A"
5. In cell B1, enter the formula: =VLOOKUP(A1,$D$1:$E$7,2)
6. Copy the contents of cell B1down to cell Bn where n is the count of
rows
7. You should now see the correct reference numbers in column B.

If you want to get more sophisticated, you can also validate column A
values by comparing its contents with a VLookup on column 1 of the
lookup range, and also by trapping #N/A with ISNA. Drop me a line at
fisherofsouls AT (not cold !)mail.com if you want to know more.

Regards

Nick

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default VBA or Vlookup?

No

Not sure what you mean. Non-unique in Col A, so is each ref in Col B
different for categories in Col A. Need more details???

"Hoshyar" wrote:

Hi DeanO and xPete,

many thanks for your prompt answer. however, this is still not working as I
wanted. These categories may appear sevral times in column (A1:A2000). So
the argument will be. in each cell of B1:B2000 I want to see the reference
number specified to its category. Does this formula works? =Vlookup ("IT
Equip","SHE Equip", "Comms Equip", A:B,2,False)

Please advise
Hoshyar

"DeanO" wrote:

I would use VLOOKUP every time!

e.g =Vlookup("IT Equip", A:B, 2, False)

would return 500

Any good? You can of cause change "It Equip" in above to any cell!


"Hoshyar" wrote:

Hi all,

If I have seven categories in Column A and I want to return a reference
number for each category in colum B. is there a VBA module to achieve this or
it is better with Vloop up?

The table looks like this.

Column A Column B
_________ ____________
Office Equip 100
Ops Equip 200
SHE Equip 300
Security Equip 400
It Equip 500
Comms Equip 600
Vehicels Equip 700


any help on this is appreciated

Best regards
hoshyar

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default VBA or Vlookup?

Hi Nick,

Many thanks, the formula you seggest has achieved what I wanted. I have also
sent you an email on your (very hot) mail.com. I would appreciate if you can
have a look at it.
I would also thank all you guys who made efforts in helping me.
Best regards
Hoshyar

" wrote:

Hoshyar,

If I've understood your requirement correctly, it is as follows:

(a) You have a column of data with 0 < rowcount < 2000 or thereabouts

(b) A valid entry in the column must be one of seven category names, as
follows:
1. Office Equip
2. Ops Equip
3. SHE Equip
4. Security Equip
5. It Equip
6. Comms Equip
7. Vehicels Equip

(c) For each row in your column of data, you want to return a
corresponding reference
number, as per the following:
Category Ref
1. Office Equip 100
2. Ops Equip 200
3. SHE Equip 300
4. Security Equip 400
5. It Equip 500
6. Comms Equip 600
7. Vehicels Equip 700

I would do it like this:

1. Copy your column of data to the range A1:An where n is the count of
rows
2. In the range D1:D7, enter the category names
3. In the range E1:E7, enter the corresponding reference numbers
4. Sort the range D1:E7 on "Column A"
5. In cell B1, enter the formula: =VLOOKUP(A1,$D$1:$E$7,2)
6. Copy the contents of cell B1down to cell Bn where n is the count of
rows
7. You should now see the correct reference numbers in column B.

If you want to get more sophisticated, you can also validate column A
values by comparing its contents with a VLookup on column 1 of the
lookup range, and also by trapping #N/A with ISNA. Drop me a line at
fisherofsouls AT (not cold !)mail.com if you want to know more.

Regards

Nick


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If (Vlookup 0) working, but what if Vlookup cell does not exist Steve Excel Worksheet Functions 18 November 18th 09 07:33 PM
VLookUp - Does the VLookUp return the exact information? Cpviv Excel Worksheet Functions 2 October 28th 08 09:57 AM
Vlookup in vlookup - taking the result as array name SupperDuck Excel Worksheet Functions 2 June 2nd 07 11:05 AM
Vlookup -=VLOOKUP(F9,LookUp1!$A$2:$B$1504,2,FALSE) MikeR-Oz New Users to Excel 1 March 22nd 06 09:01 AM
Vlookup info being used without vlookup table attached? Excel Worksheet Functions 0 January 25th 05 10:43 AM


All times are GMT +1. The time now is 06:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"