Query related to VBA with formula

Iron Contributor

Hello Everyone, 


I want to apply VLOOKUP FUNCTION formula in filtered cells only with the help of VBA code. So, what should i write VBA code to give VLOOKUP FUNCTION and it should be dynamic ??


Please help.


Here is a attached file.

8 Replies

@Excel If you know anything about VBA already, then you are going to have to declare 5 array variable(s). For example, when you declare your DIM statement, here are the variables that I would declare:


Dim varDept as String()

Dim varEmpID as String()

Dim varFName as String()

Dim varLName as String()

Dim varPayRate as Currency()


Then, later, you will have to use the ReDim statement to walk through the columns on your Data spreadsheet and then read the values into each of the above declared array variables. You will require a loop variable to walk through each row.


After you have read the data into these array variables and have them stored in memory, you can then choose to output them to your other worksheet.



Sir, actually i am learning VBA.
Can you please full VBA code ? Please

@Excel Start with this Microsoft Support link about arrays: https://docs.microsoft.com/en-us/office/vba/language/concepts/getting-started/using-arrays


And then search from here within this site for ReDim Preserve as well.


This will get you started.



Sir, Can we do more dynamic ?
Sir, can you please write VBA code ? Please.


You should at least make an effort to write the code.

If you only ask others to write all the code for you, you will never learn.

@Excel did the link to textbook I added to my first response to you help....

I have done with the help of Macro recording.
Thank you so much sir.