subscript out of range error for .csv file and vlookup

  • Thread starter Thread starter cultgag
  • Start date Start date
C

cultgag

I'm trying to use vlookup to match some part numbers with data in a .csv
file and so far have been unsuccessful. The highlighted portion keeps
on giving a "Subscript out of Range" and when I scroll over
range_lookup it gives me a message reading "range_lookup = nothing"

lookup_row_value = Sheet3.Cells(row_Numb, 1).Value

*Set Range_Lookup = Workbooks("Inv.csv"). _
Worksheets("Sheet1").Range("a1:g400")*
found_value = Application.VLookup(lookup_row_value, _
Range_Lookup, 5, False)

Sheet3.Cells(row_Numb, 5).Value = found_value

TIA

Matt
 
Assuming the highlights come through as asterisks...

Set Range_Lookup = Workbooks("Inv.csv").worksheets("Sheet1").Range("a1:g400")
When you open the .csv file, you'll see that that sheet is named after the
filename.

This may work:
Set Range_Lookup = Workbooks("Inv.csv").worksheets("Inv").Range("a1:g400")

But I'd use:
Set Range_Lookup = Workbooks("Inv.csv").worksheets(1).Range("a1:g400")

Since there's only one sheet in that .csv workbook.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top