Hi all! I have a macro that fills a sheet automatically using .Cells().Value=Application.Vlookup()....
Basically all I want to do is change the Vlookup to Index(Match()). I know the first thing is to call the index function with Application.WorksheetFunction.Index() etc..
I have a workbook with a Sheet called "Avauspohja" where I have the macro filling data. In "Avauspohja" the lookup_value is in column "M"
I also have a Sheet called "SyndicationData" which includes the raw data. In "SyndicationData" the vlookup_value is in column "D" (and all the data im searching for is to the right, I used max range of "D:XXX")
I want to use Index match because the number of columns in "SyndicationData" is not constant (Example below)
THE PROBLEM is that I receive empty results. No errors. Just blank.
Old Code with Vlookup:
New Code with Index(match()):
I made the row match look in range "D:D" because the lookup_value is in column "D"
I made the column match look in range "1:5" because the headers for the raw data are in rows 2-3
Note 1: The data im trying to return in vlookup code is a Customs Tariff Number which usually is located in column "M" in "SyndicationData" sheet but it can also be e.g. in column "P".
Note 2: The code example is a part of a loop hence the i-values.
Why does my index match result in blank cell?
If you need more information I'm more than happy to provide.
Cheers,
puupanda
Basically all I want to do is change the Vlookup to Index(Match()). I know the first thing is to call the index function with Application.WorksheetFunction.Index() etc..
I have a workbook with a Sheet called "Avauspohja" where I have the macro filling data. In "Avauspohja" the lookup_value is in column "M"
I also have a Sheet called "SyndicationData" which includes the raw data. In "SyndicationData" the vlookup_value is in column "D" (and all the data im searching for is to the right, I used max range of "D:XXX")
I want to use Index match because the number of columns in "SyndicationData" is not constant (Example below)
THE PROBLEM is that I receive empty results. No errors. Just blank.
Old Code with Vlookup:
Code:
.Cells(i, "AA").Value = Application.VLookup(.Cells(i, "M").Value, Worksheets("SyndicationData").Range("D:M"), 10, 0)
New Code with Index(match()):
Code:
.Cells(i, "AA").Value = Application.WorksheetFunction.Index(Sheets("SyndicationData").Range("D:XXX"), Application.WorksheetFunction.Match(.Cells(i, "M").Value, _
Sheets("SyndicationData").Range("D:D"), 0), Application.WorksheetFunction.Match("Customs Tariff Number (CustomsTariffNumber)", Sheets("SyndicationData").Range("1:5"), 0))
I made the row match look in range "D:D" because the lookup_value is in column "D"
I made the column match look in range "1:5" because the headers for the raw data are in rows 2-3
Note 1: The data im trying to return in vlookup code is a Customs Tariff Number which usually is located in column "M" in "SyndicationData" sheet but it can also be e.g. in column "P".
Note 2: The code example is a part of a loop hence the i-values.
Why does my index match result in blank cell?
If you need more information I'm more than happy to provide.
Cheers,
puupanda