user9990184
user9990184

Reputation: 133

VBA last row command

I am creating a VLOOKUP in VBA and it works fine but I am not able to define as "range" only the cells in column A that contain a value. The below line takes into account all column A and its giving me error messages for all the empty cells in the column. Any idea how can I fix the syntax?

   Set lookFor = book1.Sheets(1).Range("A3" & LastRow)

Upvotes: 2

Views: 171

Answers (1)

user4039065
user4039065

Reputation:

Use SpecialCells to locate text and number constants.

Set lookFor = book1.Sheets(1).Range("A1:A" & LastRow).SpecialCells(xlCellTypeConstants, xlNumbers+xlTextValues)

Upvotes: 3

Related Questions