Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Macro to hide colums with value of zero or blank

I need to hide columns in all worksheets in the workbook that have only zeros
or only blank cells after the first two rows. For example, Column A is
headed Names, Col B - Fee 1 and Col C - Fee2 and Col D - Comments. If all of
the fees under Fee2 are 0, then I want to hide the entire column. If there
are no comments, then I want to hide that column as well. The column
headings are in row 2. Can anyone help with this?
--
Thank you, Jodie
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Macro to hide colums with value of zero or blank

If desired, send your file to my address below. I will only look if:
1. You send a copy of this message on an inserted sheet
2. You give me the newsgroup and the subject line
3. You send a clear explanation of what you want
4. You send before/after examples and expected results.


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Jodie" wrote in message
...
I need to hide columns in all worksheets in the workbook that have only
zeros
or only blank cells after the first two rows. For example, Column A is
headed Names, Col B - Fee 1 and Col C - Fee2 and Col D - Comments. If all
of
the fees under Fee2 are 0, then I want to hide the entire column. If
there
are no comments, then I want to hide that column as well. The column
headings are in row 2. Can anyone help with this?
--
Thank you, Jodie


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Macro to hide colums with value of zero or blank

I just sent you an email with the information that you requested.
--
Thank you, Jodie


"Don Guillett" wrote:

If desired, send your file to my address below. I will only look if:
1. You send a copy of this message on an inserted sheet
2. You give me the newsgroup and the subject line
3. You send a clear explanation of what you want
4. You send before/after examples and expected results.


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Jodie" wrote in message
...
I need to hide columns in all worksheets in the workbook that have only
zeros
or only blank cells after the first two rows. For example, Column A is
headed Names, Col B - Fee 1 and Col C - Fee2 and Col D - Comments. If all
of
the fees under Fee2 are 0, then I want to hide the entire column. If
there
are no comments, then I want to hide that column as well. The column
headings are in row 2. Can anyone help with this?
--
Thank you, Jodie


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Macro to hide colums with value of zero or blank

For the wb presented, this should do it

Option Explicit
Sub HideBlankColumnsSAS()
Dim w As Long
Dim lc As Long
Dim i As Long
Dim mc As Long

For w = 1 To Worksheets.Count
With Sheets(w)
..Columns.Hidden = False
lc = .Cells(2, Columns.Count).End(xlToLeft).Column

For i = lc To 7 Step -1
mc = Application.CountA(.Columns(i))
If mc < 2 Or mc 1 And Application.Sum(.Columns(i)) = 0 Then
.Columns(i).Hidden = True
End If
Next i

End With
Next w
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Jodie" wrote in message
...
I need to hide columns in all worksheets in the workbook that have only
zeros
or only blank cells after the first two rows. For example, Column A is
headed Names, Col B - Fee 1 and Col C - Fee2 and Col D - Comments. If all
of
the fees under Fee2 are 0, then I want to hide the entire column. If
there
are no comments, then I want to hide that column as well. The column
headings are in row 2. Can anyone help with this?
--
Thank you, Jodie


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
MACRO TO HIDE BLANK ROWS keyson2004 Excel Programming 6 December 11th 08 01:49 PM
Macro to Hide blank rows manfareed Excel Programming 4 May 21st 08 10:00 AM
Macro to hide blank rows Alan Smith Excel Programming 3 February 23rd 07 04:35 PM
Macro to hide rows/colums by value [email protected] Excel Programming 7 September 14th 06 02:45 PM
Macro to Hide Colums keen learner Excel Programming 2 March 8th 06 12:10 PM


All times are GMT +1. The time now is 04:05 AM.

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"