#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
lehigh46
 
Posts: n/a
Default Hiding Columns

Hi All,

I know this sounds a bit far fetched but, is it possible to hide
columns based on the contents of a row of cells?

ie: if columns R, S & U have zero results then hide those columns

Thank you for not laughing and thank you for your help.

Tom Snyder
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gary''s Student
 
Posts: n/a
Default Hiding Columns

Not farfetched Tom:

You could write a macro that would detect the zero values and set the column
widths to zero or set columnhide to true.
--
Gary's Student


"lehigh46" wrote:

Hi All,

I know this sounds a bit far fetched but, is it possible to hide
columns based on the contents of a row of cells?

ie: if columns R, S & U have zero results then hide those columns

Thank you for not laughing and thank you for your help.

Tom Snyder

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
PeterAtherton
 
Posts: n/a
Default Hiding Columns

Tom

This macro will do the trick for you

Sub HideCols()
Dim j As Integer, rng As Range
' unhide columns R to U
Range("R1:U1").EntireColumn.Hidden = False
For j = 18 To 19
Set rng = Range(Cells(1, j), Cells(65536, j))
If Application.CountA(rng) 0 Then
Columns(j).Hidden = False
Else: Columns(j).Hidden = True
End If
Next
Set rng = Range(Cells(1, 21), Cells(65536, 21))
If Application.CountA(rng) 0 Then
Columns(j).Hidden = False
Else: Columns(j).Hidden = True
End If
End Sub

Open a Module, Alt + F11, Add a module and copy the macro.
Return to your worksheet and choose Tools, Macro, Run Macro (or just press
Alt + F8) select the macro and press run.

You can assign a shortcut key or draw a command button on your worksheet and
assign the macro to the command.

Regards
Peter


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
how to combine several columns into a single column jims Excel Discussion (Misc queries) 9 August 15th 05 12:00 PM
Hiding multiple columns MDavis Excel Discussion (Misc queries) 1 July 25th 05 08:46 PM
Removing Near-Duplicate Rows, Leaving Those w/Most Data in Specific Columns foofoo Excel Discussion (Misc queries) 1 April 2nd 05 12:02 AM
Hiding columns Adam Excel Discussion (Misc queries) 2 March 31st 05 05:07 PM
Counting the Contents of Two Columns Molochi Excel Discussion (Misc queries) 6 December 22nd 04 08:13 PM


All times are GMT +1. The time now is 02:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"