Hello folks,
I am a novice with VBA programming in Excel.
I am trying to do a simple VLOOKUP of Sheet1, Column B Values in Sheet2,Column1
As you can see from attachment VLOOKUP function in Excel but I am unable to get this simple thing done using a macro.
Please advise/help.
Thanks,
Gaurav
Not sure I understand what you want to do with a macro but:
Range("C2").FormulaR1C1 = "=VLOOKUP(RC[-1],Sheet2!R1C1:R6C1,1,FALSE)"
Or:
Range("C2:C11").FormulaR1C1 = "=VLOOKUP(RC[-1],Sheet2!R1C1:R6C1,1,FALSE)"
Regards
Thanks !
I have recorded a similar macro but the problem comes when my column positions are not fixed.
It would be really helpful, if some code snippet can be shared which does not use R1C1 format.
-Gaurav
Why do you need VBA to add the formula?
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Hi sgaurav
Welcome to the forum
As Roy says it may be a sledgehammer to crack a nut but .. you're the customer!
I have attached a probably lengthy solution (loop within a loop) but if it gives you ideas and takes you forward with your VBA coding then its worth it.
Roy and others can make this more efficient and more elegant.
barry
Barry - Thanks !
This helps.
Roy,
I have to perform some repititive data analysis. The task and data format is fixed but not the data.
Hence I tried by creating a simple dummy excel to see how VLookup query will be coded in macro which I can finally extend to real data.
Thanks,
Gaurav
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks