Forum Discussion

Excel's avatar
Excel
Iron Contributor
Jul 22, 2022

Query related to VBA with formula

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

  • cool2021's avatar
    cool2021
    Iron Contributor

    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.

     

    Thanks

    • Excel's avatar
      Excel
      Iron Contributor
      Sir, actually i am learning VBA.
      Can you please full VBA code ? Please
      • cool2021's avatar
        cool2021
        Iron Contributor

        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.

         

        Thanks

Resources