Hello Determined,
This macro will select the ActiveCell to the last column in the UsedRange down to the row above the first empty row found. Checks are made to ensure the ActiveCell is not in a blank row or outside the UsedRange (Data area).
Sub SelectRows()
Dim SearchRng As Range
StartRow = ActiveCell.Row
StartCol = ActiveCell.Column
ColCount = ActiveSheet.UsedRange.Columns.Count
FirstCol = ActiveSheet.UsedRange.Column
If Intersect(ActiveCell, ActiveSheet.UsedRange) Is Nothing Then
MsgBox "Your selection is outside the data."
Exit Sub
End If
With ActiveSheet
Set SearchRng = .Range(Cells(StartRow, FirstCol), Cells(.UsedRange.Rows.Count, ColCount))
End With
For Each CurRow In SearchRng.Rows
Set TestRow = CurRow.SpecialCells(xlCellTypeBlanks)
If TestRow.Columns.Count = ColCount Then
If Not Intersect(ActiveCell, TestRow) Is Nothing Then
MsgBox "You have selected an empty row."
Exit Sub
End If
LastRow = CurRow.Row - 1
ActiveSheet.Range(Cells(StartRow, StartCol), Cells(LastRow, ColCount)).Select
Exit Sub
End If
Next CurRow
End Sub
Sincerely,
Leith Ross
Bookmarks