Hiding Columns

  • Thread starter Thread starter Jane
  • Start date Start date
J

Jane

I have a spreadsheet where 5 identical sheets feed into a
summary sheet. The columns are dates where people enter
the time that they have spent on a certain job. In the
summary sheet I have a formula adding the corresponding
cell in each of the sheets. I was wondering if anybody
knew how I could hide a column on the summary sheet only
if the formula result is zero from the data coming from
the 5 other sheets.

Thanks,
Jane
 
And if you really meant columns, you could use a macro:

Option Explicit
Sub testme01()

Dim iCol As Long
Dim wks As Worksheet

Set wks = Worksheets("sheet1")
With wks
For iCol = .Range("C1").Column To .Range("g1").Column 'E:G???
If .Cells(3, iCol).Value = 0 Then
.Columns(iCol).Hidden = True
Else
.Columns(iCol).Hidden = False
End If
Next iCol
End With
End Sub

I limited my search to E:G and assumed that the cell that summed the data was in
row 3 of that column.

And if you're new to macros, you can read some notes at David McRitchie's site:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Back
Top