If you want to replace or select non-blank cells on the particular columns in active sheet, use the below codes:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
Sub SelectAllNonBlankCell() Dim rCell As Range Dim rFullRange As Range For Each rCell In ActiveSheet.UsedRange On Error Resume Next If rCell <> "" Then Set rFullRange = Union(rCell, IIf(rFullRange Is Nothing, rCell, rFullRange)) End If On Error GoTo 0 Next rCell rFullRange.Select End Sub |
Input: I have selected Non blank cells on the Active Sheet and replaced with 1. Result: