I've tried Dim CellA As Long
, As Integer
and As Range
trying to save the address of a cell. In this example, (using Range) I get the
Run Time Error 91 Object variable or with block variable not set
on line 4: CellA = Cells(ActiveCell.Row - 1, 1)
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ColA As String
Dim ColB As String
Dim CellA As Range
CellA = Cells(ActiveCell.Row - 1, 1)
If (Len(Cells(ActiveCell.Row - 1, 1) > 0)) Then
ColA = CleanCode(Cells(ActiveCell.Row - 1, 1))
ColB = CleanCode(Cells(ActiveCell.Row - 1, 2))
If (ColA <> ColB) Then
MsgBox (Cells(ActiveCell.Row - 1, 2))
Range(Cells(ActiveCell.Row - 1, 1)).Select
End If
End If
End Sub
I would like to replace all my Cells(ActiveCell.Row...)
references with variable references including my range select (which obviously doesn't work as it stands).
FYI: This routine generates a message box with the contents of a (hidden) column B cell when what I type in a column A cell doesn't match that column B cell. I wrote it to help me memorize my lines for my video head-shots.