Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Hiding Unused Rows

I have a procedure that hides rows in a budget spreadsheet that have no
value when there is a sum in the row. I would also like it to NOT hide
the row if the row in column A - the category, has a text value in it.
Some of these categories are using column A and B formatted continuous.

Here is the procedure as it stands. Some of the code is not necessary.
Will clean up later.

Regards,

Dave Johnston

Sub HideRows()
'On Error Resume Next

Dim bottomright As Range
Dim topleft As Range
Dim CategoryColumn As Range

Set topleft = ActiveSheet.Range("A10")
'topleft.Select
'MsgBox ActiveWindow.RangeSelection.Address
Set rightedge = topleft.Offset(0, 5)
'Set rightedge = topleft.End(xlToRight)
'rightedge.Select
'MsgBox ActiveWindow.RangeSelection.Address
'Set bottomright = rightedge.End(xlDown)
Set bottomright = rightedge.Offset(240, 0)
'bottomright.Select
'MsgBox ActiveWindow.RangeSelection.Address
'bottomright = bottomright.Address(, , xlA1)
With Range(topleft.Address(, , xlA1) & ":" & bottomright.Address(, ,
xlA1))
'With Range("A10:F222")
..EntireRow.Hidden = False


For i = 1 To .Rows.Count
'Trying to set a range for column A and the row number that is being
checked
'so that if column A has anything in it the row is NOT hidden
'Set CategoryColumn = topleft.Address(, , xlA1)
'And IsEmpty(.Rows(i))
If WorksheetFunction.IsText(.Rows(i)) = False Then '.Rows(i)
shows value 1 being the first row starting at the beginning of the
range
If WorksheetFunction.Sum(.Rows(i)) = 0 Then 'I need it to show
row 10
.Rows(i).EntireRow.Hidden = True
End If
'End If


Next i
End With
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Hiding Unused Rows

I found the solution and here it is.




Sub HideRows()
On Error Resume Next


ActiveSheet.Unprotect

With Range("E10:F247")
..EntireRow.Hidden = False
For i = 1 To .Rows.Count

'MsgBox WorksheetFunction.CountBlank(.Rows(i))

If WorksheetFunction.CountBlank(.Rows(i)) < 2 Then
If WorksheetFunction.Sum(.Rows(i)) = 0 Then
.Rows(i).EntireRow.Hidden = True
End If
End If


Next i
End With

ActiveSheet.protect

End Sub


wrote:
I have a procedure that hides rows in a budget spreadsheet that have no
value when there is a sum in the row. I would also like it to NOT hide
the row if the row in column A - the category, has a text value in it.
Some of these categories are using column A and B formatted continuous.

Here is the procedure as it stands. Some of the code is not necessary.
Will clean up later.

Regards,

Dave Johnston

Sub HideRows()
'On Error Resume Next

Dim bottomright As Range
Dim topleft As Range
Dim CategoryColumn As Range

Set topleft = ActiveSheet.Range("A10")
'topleft.Select
'MsgBox ActiveWindow.RangeSelection.Address
Set rightedge = topleft.Offset(0, 5)
'Set rightedge = topleft.End(xlToRight)
'rightedge.Select
'MsgBox ActiveWindow.RangeSelection.Address
'Set bottomright = rightedge.End(xlDown)
Set bottomright = rightedge.Offset(240, 0)
'bottomright.Select
'MsgBox ActiveWindow.RangeSelection.Address
'bottomright = bottomright.Address(, , xlA1)
With Range(topleft.Address(, , xlA1) & ":" & bottomright.Address(, ,
xlA1))
'With Range("A10:F222")
.EntireRow.Hidden = False


For i = 1 To .Rows.Count
'Trying to set a range for column A and the row number that is being
checked
'so that if column A has anything in it the row is NOT hidden
'Set CategoryColumn = topleft.Address(, , xlA1)
'And IsEmpty(.Rows(i))
If WorksheetFunction.IsText(.Rows(i)) = False Then '.Rows(i)
shows value 1 being the first row starting at the beginning of the
range
If WorksheetFunction.Sum(.Rows(i)) = 0 Then 'I need it to show
row 10
.Rows(i).EntireRow.Hidden = True
End If
'End If


Next i
End With
End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
hiding unused categories in charts Compensation Analyst Excel Discussion (Misc queries) 1 March 19th 07 09:22 PM
Hiding unused rows [email protected] Excel Programming 1 January 17th 07 08:22 PM
Hiding unused columns Darin Kramer Excel Programming 3 September 15th 06 12:27 PM
Having a floating row or hiding unused rows? Simon Lloyd[_764_] Excel Programming 5 June 14th 06 09:45 PM
After hiding unused columns to the right, border on right disappea Oldemom Excel Discussion (Misc queries) 0 January 17th 06 03:16 PM


All times are GMT +1. The time now is 10:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"