RockandGrohl
Well-known Member
- Joined
- Aug 1, 2018
- Messages
- 810
- Office Version
- 365
- Platform
- Windows
Hi all, venturing into the wild world of For Each instead of Do Until loops, have the following:
What I'm struggling with is how to get it to loop through each visible cell. It seems to do the first visible cell, but no others in the range?
I'm sure once I've got that, I can just put in the IF LEN blah blah blah part.
Cheers!
Code:
Dim LastrowAD As LongDim cl As Range
Dim visrng As Range
LastrowAD = Cells(Rows.Count, "A").End(xlUp).Row
Set visrng = Range("A2:A" & LastrowAD)
For Each cl In visrng.SpecialCells(xlCellTypeVisible)
'>>IF LEN OF CELL IN COLUMN A IS >6, THEN GET THE LEFT 6 CHARACTERS, OTHERWISE JUST REPEAT THE CELL<<
Next
What I'm struggling with is how to get it to loop through each visible cell. It seems to do the first visible cell, but no others in the range?
I'm sure once I've got that, I can just put in the IF LEN blah blah blah part.
Cheers!