“Unable to get the VLookup property of the WorksheetFunction Class” error

lougs7

New Member
Joined
Oct 9, 2015
Messages
6
Hi all, I am trying to set the values in column B in my Workbook "Copy of Dash Board Shell" (shown in the image below) equal to the value derived from my HLOOKUP function from my data workbook shown as second image below

Copy of Dash Board Shell
423939d1444420800-unable-to-get-the-vlookup-property-of-the-worksheetfunction-class-error-capture.png


Data file
423940d1444420841-unable-to-get-the-vlookup-property-of-the-worksheetfunction-class-error-capture-1.png


so esentially the code will find a match in the data file and copy its MIS number and paste it in the desired location on the Dash Board file, heres my code, I keep getting an error because I dont know the syntax, can someone help?


Code:
<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit;">Sub RetrieveData()

    Dim wbDash              As Workbook 'workbook where the data is to be pasted
    Dim wbData              As Workbook 'workbook from where the data is to copied
      
    
    'set to the current active workbook to Dashboard
    Set wbDash = ActiveWorkbook
    'Setting data sheet
    Set wbData = Workbooks.Open("C:\Users\673157897\Documents\Pro Fees Dash Board\Copy of Data.xls")
  
    Workbooks("Copy of Dash Board Shell").Worksheets("Data").Activate
       
With Sheets("Data")

    ' Selects the first cell to check
    Range("A3").Select
    Dim x As Variant
    x = wbData.Worksheets("Sheet1").Range("A2:B7")
    Workbooks("Copy of Dash Board Shell").Worksheets("Data").Range("A3").Select
   
    ' Loops through all rows until an empty row is found
    Do Until IsEmpty(ActiveCell)

        Range(ActiveCell.Offset(0, 1) & ActiveCell.Row).Value = Application.WorksheetFunction.VLookup((ActiveCell.Column & ActiveCell.Row), x, 2, 0)
        ActiveCell.Offset(1, 0).Select

' error is the syntax of the VLOOKUP

    Loop
End With

Call wbData.Close(False)
End Sub

</code>
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
This:<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit;">

Range(ActiveCell.Offset(0, 1) & ActiveCell.Row)

is not a valid range object.
</code><code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit;">
</code>
 
Upvote 0
This:<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit;">

Range(ActiveCell.Offset(0, 1) & ActiveCell.Row)

is not a valid range object.
</code><code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit;">
</code>


I cahnged it to this...

"Range(ActiveCell.Offset (0,1).Value=WorksheetFunction.VLookup(ActiveCell, x, 2, 0)"

and I stillg et an error with syntax, do you know how to do this?
 
Upvote 0
I cahnged it to this...

"Range(ActiveCell.Offset (0,1).Value=WorksheetFunction.VLookup(ActiveCell, x, 2, 0)"

and I stillg et an error with syntax, do you know how to do this?
Try like this:

ActiveCell.Offset (0,1).Value=WorksheetFunction.VLookup(ActiveCell, x, 2, 0)
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top