Hi guys I thought my code was running fine until today:/ Im running this macro that flooks trough columns and and finds the highest value. But I also need to know where It found this value. My code is like this:
With Sheets("Data")
lastRow = .Cells(.Rows.Count, "C").End(xlUp).Row
Vdata = .Range("K12:U" & lastRow)
vResult = .Range("W12:Y" & lastRow)
For i = LBound(Vdata, 1) To UBound(Vdata, 1)
If Vdata(i, 1) <> "" Or Vdata(i, 5) <> "" Or Vdata(i, 9) Then
vResult(i, 1) = Application.Max(Vdata(i, 1), Vdata(i, 5), Vdata(i, 9))
vResult(i, 2) = Application.Max(Vdata(i, 2), Vdata(i, 6), Vdata(i, 10))
vResult(i, 3) = Application.Max(Vdata(i, 3), Vdata(i, 7), Vdata(i, 11))
h = Application.Max(Vdata(i, 1), Vdata(i, 5), Vdata(i, 9))
d = Application.Max(Vdata(i, 2), Vdata(i, 6), Vdata(i, 10))
a = Application.Max(Vdata(i, 3), Vdata(i, 7), Vdata(i, 11))
On Error Resume Next
RecColH = Application.WorksheetFunction.Match(h, .Range("K" & i + 11 & ":U" & i + 11), 0)
RecColD = Application.WorksheetFunction.Match(d, .Range("K" & i + 11 & ":U" & i + 11), 0)
RecColA = Application.WorksheetFunction.Match(a, .Range("K" & i + 11 & ":U" & i + 11), 0)
......
So the Max code does indeed find the max value however:
RecColH = Application.WorksheetFunction.Match(h, .Range("K" & i + 11 & ":U" & i + 11), 0)
RecColD = Application.WorksheetFunction.Match(d, .Range("K" & i + 11 & ":U" & i + 11), 0)
RecColA = Application.WorksheetFunction.Match(a, .Range("K" & i + 11 & ":U" & i + 11), 0)
Is supposed to find the placement , which it does unless some values are the same. As this looks trough all the columns from K-U and as you can see with the vdata variable it should only search like this:
RecColH should return the Col with the max value of: Col "K","O", "S"
RecColD should return the Col with the max value of: Col "L","P", "T"
RecColA should return the Col with the max value of: Col "M","Q", "U"
Ive tried just real quick test:
RecColH = Application.WorksheetFunction.Match(h, Vdata(i, 3), Vdata(i, 7), Vdata(i, 11), 0)
RecColD = Application.WorksheetFunction.Match(d, Vdata(i, 3), Vdata(i, 7), Vdata(i, 11), 0)
RecColA = Application.WorksheetFunction.Match(a, Vdata(i, 3), Vdata(i, 7), Vdata(i, 11), 0)
But that is not working im unsure how I should phrase it.?
any help with this would be much appreciated as im stuck here at this problem :/
Bookmarks