calwood28
asked on
Hide Blank Cells in Excel
I need to know how to hide blank cells in Excel 2007. I have a created a simple workbook. There are two worksheets in the workbook. One worksheet (we'll call the worksheet "Data") contains data retrieved from a time management system. The "Data" worksheet contains numerical values. The second worksheet (we'll call it "Figures") contains two columns. The first column consists of task numbers that are used for simple reference only. The second column contains a SUMIF formula that looks to the "Data" worksheet - =SUMIF(Data!$D$1:$D$10000, "002 Review Job Plans ",Data!$G$1:$G$10000). Since the majority of the cells are blank I need a simple way to hide them so that I can see only the cells that contain a numerical value greater than 0. Note: some of the cells contain a formula that returns a value of 0 and some cells contain no formula. Thank you for your help!
Hi,
If you like VBA approach, then put this code in the 'Figures' sheet module.
Right click on Sheet name > View code and paste the code there.
Close the VBE window. Now the code will fire when calculation happens.
Kris
If you like VBA approach, then put this code in the 'Figures' sheet module.
Right click on Sheet name > View code and paste the code there.
Close the VBE window. Now the code will fire when calculation happens.
Kris
Oops ! missed the code. Here you go.
Private Sub Worksheet_Calculate()
Dim r As Range, k, i As Long, n As Long, a() As String, txt As String
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set r = Me.UsedRange.Columns("b:B"
r.EntireRow.Hidden = False
k = r
On Error GoTo Xit
If Not r Is Nothing Then
For i = 1 To UBound(k, 1)
If Len(k(i, 1)) = 0 Or k(i, 1) = 0 Then
txt = txt & "," & "a" & i
If Len(txt) > 245 Then
n = n + 1
ReDim Preserve a(1 To n)
a(n) = Mid$(txt, 2)
txt = vbNullString
End If
End If
Next
If Len(txt) > 1 Then
n = n + 1
ReDim Preserve a(1 To n)
a(n) = Mid$(txt, 2)
txt = vbNullString
End If
If n Then
With r
For i = 1 To n
.Range(CStr(a(i))).EntireR
Next
End With
End If
End If
Xit:
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub
Kris
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Range(yourRange).Sort
There is no easy way to 'hide' individual cells...