how to apply match in loop in vba
I am completely stucked with applying match function in my code. This below is part only my code; previous part is copying cells / rows from sources to result sheet, and this planned function to check status of copy...happened or not If match, answer OK, if not, than let empty the cell. But simply not works and code stops each case at "res" and no idea what. Ive learned that match has problem if result is error, so Tried On error resume next, On error go to issues, Read same codes which works, but cannot see the problem in my one, however looking for about a week No idea and cannot move forward however sure that solution is quite simple only my knowledge is small. Thx for reading and support me
wsLCLHU
is source worksheet - wsCallLCL
is result
Sub Match()
Dim res As Variant
'firstrow is number of first visible row of copied range of source
FirstRow = foundrow
'lastrow is last nr of row of visible range of source
LastRow = lastrowHU
For row = LastRow To FirstRow Step -1
res = Application.Match(wsLCLHU.Range("H" & foundrow & ":" & "H" & lastrowHU).SpecialCells(xlCellTypeVisible), wsCallLCL.Range("I:I"), 0)
If IsError(res) Then
wsLCLHU.Range("CE" & row).Value = ""
Else
wsLCLHU.Range("CE" & row).Value = "OK"
End If
Next row
End Sub
Comments
Post a Comment