AlexanderBB
Well-known Member
- Joined
- Jul 1, 2009
- Messages
- 2,074
- Office Version
- 2019
- 2010
- Platform
- Windows
I'd like to read any comment in my worksheet. I'm going through row by row (my variable i) with code
If there's no comment I have to trap this error
Run-time error '91':
Object variable or With block variable not set
Is this an OK approach, or perhaps a better method exists ?
Thanks.
VBA Code:
For Pos = 1 To 10
CR = colLetter(Pos)
If .Range(CR & i).Comment.Text > "" Then
Stop
End If
Next
Function colLetter(intNumber) As String
If Val(intNumber) = 0 Then
colLetter = ""
Else
colLetter = Left(Cells(1, Val(intNumber)).Address(0, 0), 2 + (Val(intNumber) <= 26))
End If
End Function
Run-time error '91':
Object variable or With block variable not set
Is this an OK approach, or perhaps a better method exists ?
Thanks.