ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VB error '1004' Unable to get VLookup property to work right (https://www.excelbanter.com/excel-programming/433889-re-vbulletin-error-1004-unable-get-vlookup-property-work-right.html)

Jacob Skaria

VB error '1004' Unable to get VLookup property to work right
 
Try the below...Declared as variant,

Sub Macro()
Dim Location As Variant ' number used to look for city
Location = 1
Worksheets("Master").Activate
With ActiveSheet
..Range("V3") = Application.WorksheetFunction.VLookup(Location, _
Sheets("City").Range("A2:B3"), 2, False)
End With
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"NFL" wrote:

I'm getting a run-time error 1004 and don't know what is missing. I have 2
columns in the City worksheet as shown below. Thank you!

A B
Location City
1 Springfield
2 Dallas
3 etc. etc..

I want the Master worksheet to look for a city/town in the City worksheet
and place that value in V3.

dim Location as string ' number used to look for city

Worksheets("Master").Activate
With ActiveSheet
.Range("V3") = Application.WorksheetFunction.VLookup(Location,
Sheets("City").Range("A2:B3"), 2, False)

End With



All times are GMT +1. The time now is 03:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com