I am trying to:
Search each value in column S.
If the value = "CA", select the cell in the same row but in column I.
If the value of that cell is <= 93599, select the original cell in column S, and overwrite it with "CS".
If the (column I) cell value is > 93599, select the original cell in column S, and overwrite it with "CN".
Then continue checking the rest of the cells in column S.
Dim wks As Worksheet
Dim LastRow As Long
Dim cell As Range
Dim a As String
Set wks = ActiveWorkbook.Worksheets("Addresses")
With wks
LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
If LastRow = 1 Then
Exit Sub
End If
a = "93599"
For Each cell In .Range(.Cells(2, 19), .Cells(LastRw, 19))
If cell = "CA" Then
ActiveCell.Offset(0, -10).Select
If ActiveCell.Value <= a Then
ActiveCell.Offset(0, 10).Select
ActiveCell.Value = "CS"
Else
ActiveCell.Offset(0, 10).Select
ActiveCell.Value = "CN"
End If
End If
Next cell
End With
This code returns
"Run-time error '1004': Application-defined or object-defined error"
and highlights the ActiveCell.Offset(0, -10).Select
which suggests that a cell in column S is not selected when it's trying to perform the offset.