I am getting an OVERFLOW error when running a For statement with VBA. What can I do in order to avoid this issue?
Dim lr As Long
lr = ws.Cells(ws.Rows.Count, vcol).End(xlUp).Row
For i = 2 To lr
On Error Resume Next
If ws.Cells(i, vcol) <> "" And Application.WorksheetFunction.Match(ws.Cells(i, vcol), ws.Columns(icol), 0) = 0 Then ws.Cells(ws.Rows.Count, icol).End(xlUp).Offset(1) = ws.Cells(i, vcol)
End If
Next
I tried to add Clng(lr) but that did not work. trying to get this to work and bypass the Overflow error