MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Variables in a macro using a Vlookup Worksheet Function ... Please help.

Posted by Lael Buchanan on May 11, 2000 4:53 AM


I have a macro that I'm trying to create that is giving me some trouble. I would appreciate any help that anyone can provide.

What I've got is a macro that is supposed to lookup a value on a table and insert that value into the currently active cell. The problem that I'm having is in getting the lookup to work properly. Here's the line that is giveing me trouble:

Text = Application.WorksheetFunction.VLookup((First Variable), (Table),(Second Variable))

The Table is fixed. The first variable is a randomly determined number, and the second variable is fixed by the last time that this macro was run (or a default value if this is the first run).

What I need to know is how to get the WorksheetFunction to read the variables as their values rather than trying to use the names of the variables in the lookup. I seem to recall it being a combination of single and double quotes, but I can't remember exactly how it goes. Can anyone refresh my memory?

Thanks in advance,


Posted by Lael Buchanan on May 11, 2000 11:05 AM

I got it working. so please disregard my earlier post.