PDA

View Full Version : VBA with index + match with 2 criterion issue



teowchy
02-18-2019, 05:52 AM
Hi all,

First time posting here, I using index match formula for my report, just curious when i I increase the criterion, the result isn't shown property that i need, and it become blank while the cell is empty too.

this is the code for single criterion, no problem :
Code:
Cells(Target.Row, 4) = Application.WorksheetFunction.Index(WB.Worksheets(strWorksheets).Range("$AA:$AA"), Application.WorksheetFunction.Match(Target.Value, WB.Worksheets(strWorksheets).Range("$AB:$AB"), 0))
when Target.Value got duplicate, the result will always show the 1st result, so i try to increase the 2nd criterion, below is my code

Code:
Cells(Target.Row, 4) = Application.WorksheetFunction.Index(WB.Worksheets(strWorksheets).Range("$B:$AB"), Application.WorksheetFunction.Match(Target.Value, WB.Worksheets(strWorksheets).Range("$Y:$Y"), 0) + Application.WorksheetFunction.Match(NowSO, WB.Worksheets(strWorksheets).Range("$B:$B"), 0), 26)
if i use + between 2 match function, the result will always show the last row with non empty cell, or use - then the result is always the 1st row, how do I improve my code, as i know doing the array in VBA is using another method, but i no idea to amended it, thank in advance.