Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 34
Default vlookup macro

I have a spreadsheet that looks like data below.

UPC Commission
1234 5%
4567 Not On file
8999 3%

What I need to do is do a lookup by UPC to another spreadsheet and return
the commission %. I'm only interested in doing this for the rows in which
the Commission field says "Not On file".

The spreadsheet that I am looking up the data from is called
"Commission.xls" and has the UPC in column a and the Commission in column B.
Each time I try to right a formula to do the lookup I get an error.

Any help would be great. Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 3,365
Default vlookup macro

Start there on the row that has equivalent of the 4567 Not On File entries
and create a VLOOKUP that actually works. It might look something like this
(presumes we're in row 3) :
=VLOOKUP(A3,'[Commission.xls]TheSheetInOtherBook'!$A$1:$B$101,2,0)
which says to try to match the value in A3 on this sheet with an entry in
column B on the other book's sheet and if it finds a match, return the value
in the 2nd column of that table (column B). If it doesn't find a match it
will return a #N/A error - that is normal.

To hide the #N/A from showing up, you wrap that in a test with IF, as:
=IF(ISNA(VLOOKUP(A3,'[Commission.xls]TheSheetInOtherBook'!$A$1:$B$101,2,0),"",VLOOKUP(A 3,'[Commission.xls]TheSheetInOtherBook'!$A$1:$B$101,2,0))

Finally, since you don't want to always do this except when column B
contains the key phrase, use one more IF layer:
=IF(B3="Not On
File,IF(ISNA(VLOOKUP(A3,'[Commission.xls]TheSheetInOtherBook'!$A$1:$B$101,2,0),"",VLOOKUP(A 3,'[Commission.xls]TheSheetInOtherBook'!$A$1:$B$101,2,0)),"")


"MikeD1224" wrote:

I have a spreadsheet that looks like data below.

UPC Commission
1234 5%
4567 Not On file
8999 3%

What I need to do is do a lookup by UPC to another spreadsheet and return
the commission %. I'm only interested in doing this for the rows in which
the Commission field says "Not On file".

The spreadsheet that I am looking up the data from is called
"Commission.xls" and has the UPC in column a and the Commission in column B.
Each time I try to right a formula to do the lookup I get an error.

Any help would be great. Thanks!

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
Specifying cell(s) for Vlookup Function in Macro Bill D. Toronto Excel Discussion (Misc queries) 5 February 20th 07 09:29 PM
Replace Vlookup with a macro Arain Excel Discussion (Misc queries) 1 September 27th 06 09:32 AM
problem with Vlookup in macro Richard Excel Discussion (Misc queries) 2 June 20th 06 02:22 PM
VLOOKUP in a macro?? chip_pyp Excel Discussion (Misc queries) 1 March 27th 06 09:40 PM
Macro puts #REF in VLOOKUP formula DJH224 Excel Worksheet Functions 1 January 27th 06 05:37 PM


All times are GMT +1. The time now is 07:24 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"