Hello all;
I have a macro searching for errors throughout a worksheet. When an error is returned a message box is displayed indicating the location of the error. I would like the box to center over the offending cell. Is this possible?
What I have so far is
The line "ActiveSheet.Range(.Cells(r,2)) always throws an error. Does anyone have any ideas?
Thanks!
I have a macro searching for errors throughout a worksheet. When an error is returned a message box is displayed indicating the location of the error. I would like the box to center over the offending cell. Is this possible?
What I have so far is
Code:
Sub CheckNames()
Dim r As Long, c As Range
'Dim emptyRow As Boolean
If r_start = 0 Then r_start = 19
With ActiveSheet
For r = r_start To 5000
'Checks entire row for data. User may skip rows when entering data.
If WorksheetFunction.CountA(.Range(.Cells(r, 1), .Cells(r, 33))) > 0 Then
If ((.Cells(r, 2) = "") <> (.Cells(r, 3) = "")) Or _
((.Cells(r, 2) = "") = (.Cells(r, 4) = "")) Then
'UserForm20.Show
ActiveSheet.Range (.Cells(r, 2))
MsgBox "Please fill in First and Last Name or HCO in Row " & r & ".", vbOKCancel, "First and Last Name or HCO"
If vbCancel Then
HCPAddress
End If
End If
End If
Next
End With
'Call HCPAddress
End Sub
The line "ActiveSheet.Range(.Cells(r,2)) always throws an error. Does anyone have any ideas?
Thanks!