#1   Report Post  
carl
 
Posts: n/a
Default Modifying Macro

I use this formula in my macro:


ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[9],ref1,2,FALSE)"

Is it possible to add code that will do the lookup in "ref1" and "ref2" ?

Thank you in advance.
  #2   Report Post  
CLR
 
Posts: n/a
Default

VLOOKUP will stop when it finds a match, so I you have the same value in both
ranges it will only find the first.......however, you might consider wrapping
your VLOOKUP in an IF(ISNA..... formula so that if it does NOT find the
lookup value in the first range, then it will look in the second
range.......either that, or use two VLOOKUP formulas, one for each range.....

Vaya con Dios,
Chuck, CABGx3




"carl" wrote:

I use this formula in my macro:


ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[9],ref1,2,FALSE)"

Is it possible to add code that will do the lookup in "ref1" and "ref2" ?

Thank you in advance.

  #3   Report Post  
Excel_Geek
 
Posts: n/a
Default


Some questions, so I can try to help you...

Are ref1, ref2, and ref3, named ranges in the workbook?

What is RC[9]?


--
Excel_Geek


------------------------------------------------------------------------
Excel_Geek's Profile: http://www.excelforum.com/member.php...o&userid=26423
View this thread: http://www.excelforum.com/showthread...hreadid=399200

  #4   Report Post  
carl
 
Posts: n/a
Default

Hi. Thank you for your help. The ref1 and ref2 are named ranges in the
workbook.

The RC[9] comes from the vba code - not sure what it is.

"Excel_Geek" wrote:


Some questions, so I can try to help you...

Are ref1, ref2, and ref3, named ranges in the workbook?

What is RC[9]?


--
Excel_Geek


------------------------------------------------------------------------
Excel_Geek's Profile: http://www.excelforum.com/member.php...o&userid=26423
View this thread: http://www.excelforum.com/showthread...hreadid=399200


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
Make Alignment options under format cells available as shortcut dforrest Excel Discussion (Misc queries) 1 July 14th 05 10:58 PM
Help with macro looping and color query function kevinm Excel Discussion (Misc queries) 10 May 26th 05 01:25 AM
Modifying Sheet1 macro to run on Sheet2 Sharon Excel Discussion (Misc queries) 6 April 28th 05 01:21 PM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM


All times are GMT +1. The time now is 02:38 PM.

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

About Us

"It's about Microsoft Excel"