VLOOKUP with EVALUATE statement

jnathan

New Member
Joined
Jul 8, 2013
Messages
48
I am attempting to use VLOOKUP to automatically populate a spreadsheet with data from another workbook via a Private Sub Worksheet_Change. Basically, each time the user double-clicks a cell within Column 2 then this will activate the macro to execute the VLOOKUP and pull in the required data from the other workbook.

I thought that I had it right however I'm only getting #VALUE! when the macro runs. The code I have is shown below. Any help on why this is happening and how to resolve this will be appreciated!!!
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Dim ocDrop As String
Dim statusDrop As String
Dim esclDrop As String
If Target.Row <> 1 Then
If Target.Column = 2 Then
If IsEmpty(Target.Value) = False Then
Target.Offset(0, -1).Interior.ColorIndex = 0
Target.Offset(0, 3) = "Open"

Target.Offset(0, 20) = Evaluate("=VLOOKUP(" & Chr(34) & Target.Value & Chr(34) & ",'[MSG - Volume Alerts.xlsm]Sheet1!$A:$AC,4,FALSE)")

End If
End If
End If
End Sub
 
Last edited by a moderator:

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
It's this line of the code that is not working as expected:

Target.Offset(0, 20) = Evaluate("=VLOOKUP(" & Chr(34) & Target.Value & Chr(34) & ",'[MSG - Volume Alerts.xlsm]Sheet1!$A:$AC,4,FALSE)")
 
Upvote 0
Missing closing single quote after .xlsm
Should be

Target.Offset(0, 20) = Evaluate("=VLOOKUP(" & Chr(34) & Target.Value & Chr(34) & ",'[MSG - Volume Alerts.xlsm']Sheet1!$A:$AC,4,FALSE)")
 
Upvote 0
Hi

I'd use the single quote before the exclamation mark:

Code:
Target.Offset(0, 20) = Evaluate("=VLOOKUP(" & Chr(34) & Target.Value & Chr(34) & ",'[MSG - Volume Alerts.xlsm]Sheet1[COLOR=#FF0000][B]'[/B][/COLOR]!$A:$AC,4,FALSE)")
 
Upvote 0
Hi

I'd use the single quote before the exclamation mark:

Code:
Target.Offset(0, 20) = Evaluate("=VLOOKUP(" & Chr(34) & Target.Value & Chr(34) & ",'[MSG - Volume Alerts.xlsm]Sheet1[COLOR=#ff0000][B]'[/B][/COLOR]!$A:$AC,4,FALSE)")

Many thanks pgc01!!! That did it.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,279
Members
452,630
Latest member
OdubiYouth

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