-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathM_select_blank_rows
More file actions
42 lines (35 loc) · 988 Bytes
/
M_select_blank_rows
File metadata and controls
42 lines (35 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Sub Select_Blank_Rows()
'Select all entire blank Rows in selected range
'Made by kalaLokia
Dim rRow As Range
Dim rSelect As Range
Dim rSelection As Range
'Check that a range is selected
If TypeName(Selection) <> "Range" Then
MsgBox "Please select a range first.", vbOKOnly, "Select Blank Rows Macro"
Exit Sub
End If
'Check that multiple cells are selected
If Selection.Cells.Count = 1 Then
Set rSelection = ActiveSheet.UsedRange
Else
Set rSelection = Selection
End If
'Loop through each Row and add blank Rows to rSelect range
For Each rRow In rSelection.Rows
If WorksheetFunction.CountA(rRow) = 0 Then
If rSelect Is Nothing Then
Set rSelect = rRow
Else
Set rSelect = Union(rSelect, rRow)
End If
End If
Next rRow
'Select blank Rows
If rSelect Is Nothing Then
MsgBox "No blank Rows were found.", vbOKOnly, "Select Blank Rows Macro"
Exit Sub
Else
rSelect.Select
End If
End Sub