I wrote the following code and am trying to use a variable as the lookup value in a vlookup function. But, every time the macro runs, an error occurs with the variable bolded below.
Does anyone know why this is occurring and how to fix it?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cellvalue As Variant
cellvalue = Format(ActiveCell.Offset(0, -1).Value, "00000000000")
If Not Intersect(Target, Range("A10:A110")) Is Nothing Then
Target.Offset(0, 1).ClearContents
ActiveCell.Formula = "=vlookup(" & cellvalue & ",'Project # and Name'!A1:B2,2,FALSE)"
End If
End Sub
Thank you!!
Bookmarks