Delete empty cells in worksheet

jackdash

New member
Local time
1:05 AM
Messages
168
I am a newbie to Excel and have created a small calculation worksheet.
It only occupies a small section of the worksheet and I would like to know how to only show that part and not showing the empty cells.
I am using Microsoft Office 2007.

Thanks
jack
 

My Computer

Computer Manufacturer/Model Number
Packard Bell
OS
Windows 7 Home Premium
CPU
Intel(R) Core(TM2) Quad CPU Q8300 @ 2.50Mhz 4 Core(s)
Motherboard
Packard Bell EG43M
Memory
6.00 GB
Graphics Card(s)
Geforce GT220
Hard Drives
1.5 TB
Keyboard
Logitech Wireless
Mouse
Logitech Wireless
I am a newbie to Excel and have created a small calculation worksheet.
It only occupies a small section of the worksheet and I would like to know how to only show that part and not showing the empty cells.
I am using Microsoft Office 2007.

Thanks
jack

Check out the following:

Question
Hi, I am looking for a solution to hide columns based upon their content.

I know this is logically possible but I am struggling with the "How" and really do hope you can help me.

Background Info: I have a database which holds data from which I am building reports for users. This database has an Excel Add-In which allows me to create reports (views) in Excel to distribute to users. The Add-In has a switch which automatically suppresses any rows which has zero's in the cells across the columns.

Problem: The report I am building uses 219 columns. Most of these columns contain zero's. I would like to build a macro to hide these columns so that the users only see those columns with data in them.

Thank you in advance for your help.

Kind regards,
Reshma

Answer
Hi Reshma,

Here is a macro that will hide zero-filled or empty columns:

Sub HideEmptyColumns()

' This macro hides empty or all-zero columns in the active worksheet
' It ignores columns outside the used range (UsedRange)

Dim Col As Range

For Each Col In ActiveSheet.UsedRange.Columns
Col.EntireColumn.Hidden = AllZero(Col)
Next Col

End Sub

Sub UnhideColumns()

' This macro unhides all columns on the active worksheet

Columns.Hidden = False

End Sub

Function AllZero(R As Range) As Boolean

' This function returns TRUE if the range is entirely empty or all zero

Dim C As Range
AllZero = True

For Each C In R.Cells
If C.Value <> 0 Then
AllZero = False
Exit For
End If
Next C

End Function

I also included an UnhideColumns macro to enable you to easily unhide the hidden columns. The user-defined function AllZero is a "helper" function used by the HideEmptyColumns macro.

Simply install this code in a standard macro module just as you would any other macro. The macro will always operate on the active worksheet.

Keep Excelling.

Damon

How to: Remove all blank rows at once | asap utilities / excel blog

Excel 2007: Eliminate Blank Rows in a Spreadsheet | Microsoft Excel | Tech-Recipes

http://www.techsupportforum.com/mic...ort/275304-getting-rid-empty-cells-excel.html
 

My Computer

Computer Manufacturer/Model Number
Apple Macbook Pro (April 2009)
OS
W7 Ult. x64 | OS X
CPU
Intel Mobile Core 2 Duo 2.93Ghz [T9800 Penryn]
Motherboard
NVIDIA nForce 730i Rev. B1 [Mac-F2268EC8 (U2E1)]
Memory
4096MB Samsung DDR3 Dual Channel [PC3-8500F 1066Mhz]
Graphics Card(s)
NVIDIA GeForce 9600M GT 512MB [G96M Rev. C1]
Sound Card
SB X-Fi Surround 5.1 USB | Onboard Realtek (Disabled)
Monitor(s) Displays
Acer x223wbd 22" | Apple Anti-Glare 17" (Disabled)
Screen Resolution
{Current} 1440x900 {Acer} 1680x1050 {Apple} 1920x1200
Hard Drives
{Internal}
Seagate Momentus 320GB 2.5" 7200RPM [ST9320421AS]

{Externals}
LaCie 320GB USB 2.0 HDD [301284UR]
LaCie 750GB USB 2.0 FW400 eSATA HDD [301314U]
LaCie 1TB USB 2.0 HDD [301304UR]
PSU
Magsafe
Case
Aluminum/Unibody (MBP52)
Cooling
2 x 6000 RPM Fans
Keyboard
Logitech G-15v2 [PN 920-000379]
Mouse
Logitech G-9 [PN 910-000338]
Internet Speed
12Mbps/2.5Mbps w/ 24Mbps Speed Boost [Comcast]
Other Info
Logitech X-540 Speakers [PN 970223-0122]
Sennheiser PC-151 Headset
Back
Top