View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones[_2_] Norman Jones[_2_] is offline
external usenet poster
 
Posts: 421
Default How to insert VLOOKUP function in VBA?

Hi Dan,

Perhaps I totally misunderstand, but why
will the formula:

=VLOOKUP(A2, B2, 2, FALSE)

not meet your needs?

Each time the Userform's update button is
clicked, the values of the cells A2 and B2
will be updated and, consequently, the
result of your lookup formula will furnish the
updated result.



---
Regards.
Norman
"Dan" wrote in message
...
Hi Norman,
I am sorry, I guess I am complicating things more than they should be ;)
What I need to do is the following: I have already a UserForm that copies
two variables from Sheet1 to position of A2 and B2 in Sheet2. In Sheet2,
C3,
I need to place a VLOOKUP formula so it reads cell B2 as dynamic
table_array.
Since the 1st UserForm every time executes CommandButton it copies
different
value. For instance, it may come as "TOTAL_POPULATION" (this has to be an
table_array, pre-determined in Sheet3 and broke according to years) and
the
second variable as "Cherokee, KS". The function has to find "Cherokee, KS"
in
"TOTAL_POPULATION" table_array which is already in Sheet3 and return value
for 2000 year (that would be =VLOOKUP(A2, B2, 2, FALSE)). The reason I
wanted
to use UserForm, by inserting formula, it copies it as and "B2" and not
the
table_array. And there are about 20 table_arrays, so, that the 1st
UserForm
is used, a user has an option of selecting any other than
"TOTATL_POPULATION"
and so one. I hope that makes senss.