Hello,
Excel question: The following code does what I need except the select includes a bottom cell that has text. I need to select a range and hide it leaving a row between data sets.
Example: Column A, Rows 1-3 have data, Rows 4-6 are empty, Rows 7-10 have data. This code selects rows 4-7, I just need rows 4 and 5.
Help!
Sub SelectandHideRowsUnused()
'Begins by setting static point "A5" then finding next blank down.
Range("a5"
.Select
ActiveCell.Offset(1, 0).Select
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Select
Loop
Set TopCell = Cells(1, ActiveCell.Column)
Set BottomCell = Cells(130, ActiveCell.Column)
On Error Resume Next
If IsEmpty(ActiveCell.Offset(-1, 0)) Then Set TopCell = ActiveCell.End(xlUp) Else Set TopCell = ActiveCell
If IsEmpty(ActiveCell.Offset(1, 0)) Then Set BottomCell = ActiveCell.End(xlDown) Else Set BottomCell = ActiveCell
Range(TopCell, BottomCell).Offset(0, 0).Select
End Sub
Excel question: The following code does what I need except the select includes a bottom cell that has text. I need to select a range and hide it leaving a row between data sets.
Example: Column A, Rows 1-3 have data, Rows 4-6 are empty, Rows 7-10 have data. This code selects rows 4-7, I just need rows 4 and 5.
Help!
Sub SelectandHideRowsUnused()
'Begins by setting static point "A5" then finding next blank down.
Range("a5"
ActiveCell.Offset(1, 0).Select
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Select
Loop
Set TopCell = Cells(1, ActiveCell.Column)
Set BottomCell = Cells(130, ActiveCell.Column)
On Error Resume Next
If IsEmpty(ActiveCell.Offset(-1, 0)) Then Set TopCell = ActiveCell.End(xlUp) Else Set TopCell = ActiveCell
If IsEmpty(ActiveCell.Offset(1, 0)) Then Set BottomCell = ActiveCell.End(xlDown) Else Set BottomCell = ActiveCell
Range(TopCell, BottomCell).Offset(0, 0).Select
End Sub