AlexanderBB
Well-known Member
- Joined
- Jul 1, 2009
- Messages
- 2,097
- Office Version
- 2019
- 2010
- Platform
- Windows
I must have misunderstood how it works
Stepping show the first row with no comments goes to the Error and Next.
But the next instance crashes with error 1004 No Cells Were found.
But hasn't the error handler been reset?
VBA Code:
Sub isntworking()
Dim Comm As Range
Dim cl As Range
Dim x As Integer
With Worksheets("Sheet1")
For x = 2 To 10
Set iRange = .Range("A" & x & ":CV" & x)
On Error GoTo NoExcelComments ' handle the error that occurs if there is no cell with comments
Set Comm = iRange.SpecialCells(xlCellTypeComments)
For Each cl In Comm ' iterate over all cells in rng - each of them contains a comment
Debug.Print cl
Next
NoExcelComments:
Next
End With
End Sub
But the next instance crashes with error 1004 No Cells Were found.
But hasn't the error handler been reset?