View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Al
 
Posts: n/a
Default Hide / Unhide columns and rows

Great...I have a similar objective, and I wonder if you could advise the
appropriate solution? I'd like to be able to hide rows or columns if a
specific cell has no data.

My spreadsheet is a list of names and hours and charges, but if name X has
zero hours - i.e. hours X = 0 - then I do not need the row, otherwise my
spreadsheet will have so many unused rows, and so want to hide it. To
complicate matters, I want the rows that are the various titles to remain
unhidden, so I see something that only conisders the data rows and hides them
if the hours = zero.

Allan
"swatsp0p" wrote:

For some reason, my post via Joseph Rubin's newsgroup did not make it to here.

Assuming your worksheet is nameed "Sheet1" (edit as needed), create your
button and add this code to your button: verify the columns listed match your
desired ones to hide!

-----------------------

Sub hidecolsrow4()
' hidecolsrow4 Macro
If Worksheets("Sheet1").Columns("J").Hidden = False Then
Range("J:J,L:L,N:N,P:P,R:R,T:T,V:V,X:X,Z:Z,AB:AB,A D:AD,AF :AF,AH:AH").Select
Selection.EntireColumn.Hidden = True
Range("A4").Activate
Selection.EntireRow.Hidden = True
' unhidecolsrow4 Macro
Else
Rows("3:5").Select
Selection.EntireRow.Hidden = False
Columns("I:AI").Select
Selection.EntireColumn.Hidden = False
End If
Range("A1").Select
End Sub

----------------------------

If columns are hidden, this will Unhide them, if not hidden, it will Hide
them.

Good Luck
__________________
Bruce
The older I get, the better I used to be.
Minneapolis, MN USA