Hello,
I'm new to VBA Programming, but my first program may be a little more complicated than I can handle. Here is a segment from my code:
The VLOOKUP function will determine if the value in a cell matches a cell in a different data collection. If it is a match, the cell next to it will have the value "MATCH", but if it doesn't, the result comes out to be "#N/A". I want to be able to highlight the matched cells in pink, and I want to go about doing this with an error handler. So far, I've got the loop going through the "MATCH"'s and the first error just fine, but as soon as it gets to the second error, it gives me the runtime error "type mismatch".
I've tried several variations of this code and this is the most luck I've had. Thanks in advance to anyone who offers a solution!
I'm new to VBA Programming, but my first program may be a little more complicated than I can handle. Here is a segment from my code:
Code:
On Error GoTo Error_Handler
For i = 2 To top
With Range("I" & i + 57)
.Formula = "=VLOOKUP(H" & i + 57 & ",F$59:G$" & top + 57 & ",2, FALSE)"
.Font.Name = "Arial"
.Font.Size = 8
End With
If Range("I" & i + 57) = "MATCH" Then
Range("H" & i + 57).Interior.ColorIndex = 7
GoTo Loop_Resume
End If
Loop_Resume:
Next i
Error_Handler:
Err.Clear
On Error GoTo Error_Handler
GoTo Loop_Resume
The VLOOKUP function will determine if the value in a cell matches a cell in a different data collection. If it is a match, the cell next to it will have the value "MATCH", but if it doesn't, the result comes out to be "#N/A". I want to be able to highlight the matched cells in pink, and I want to go about doing this with an error handler. So far, I've got the loop going through the "MATCH"'s and the first error just fine, but as soon as it gets to the second error, it gives me the runtime error "type mismatch".
I've tried several variations of this code and this is the most luck I've had. Thanks in advance to anyone who offers a solution!
Last edited by a moderator: