Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Format column auto. to "hidden"

How do I set up an automatic column format to "zero" width
or hidden. What I want to do is when a particular cell
has a certain value I want another column or row to hide
itself and when the cell is changed to another value the
column will show up again. I have looking through various
excel developer books and cannot seem to find the answer.
I even tried a macro and still could not get it to work.

In other words, if cell j5 = x (text) or a number - lets
say 5 then column "b" goes to hidden or zero width ---
then when cell j5 is not the x or 5 column "b" goes back
to normal and is seen!

P.S. same for rows as well!

I hope you can help!
Thanks, Nils

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Format column auto. to "hidden"

Hi Nils
Paste the code below into the sheet code (right-click on your sheet tab and
select View code)
This will hide column B whenever any value (text or number) is entered into
J5 and unhide column B whenever J5 is empty
To hide rows change Columns to Rows and letters to numbers
ie Rows("1:1").EntireRow.hidden = True
Sample code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$J$5" Then
If Target.Value < "" Then
Columns("B:B").EntireColumn.Hidden = True
Else: Columns("B:B").EntireColumn.Hidden = False
End If
End If
End Sub

Regards
Pascal

a écrit dans le message de
...
How do I set up an automatic column format to "zero" width
or hidden. What I want to do is when a particular cell
has a certain value I want another column or row to hide
itself and when the cell is changed to another value the
column will show up again. I have looking through various
excel developer books and cannot seem to find the answer.
I even tried a macro and still could not get it to work.

In other words, if cell j5 = x (text) or a number - lets
say 5 then column "b" goes to hidden or zero width ---
then when cell j5 is not the x or 5 column "b" goes back
to normal and is seen!

P.S. same for rows as well!

I hope you can help!
Thanks, Nils



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 do I auto transform sets of data? (change "female" to "f") Liz Excel Discussion (Misc queries) 2 April 2nd 23 08:53 PM
Auto Filter - how to collapse "non-blank" cells in a column? marla Excel Discussion (Misc queries) 2 August 24th 08 10:03 PM
text string: "91E10" in csv file auto converts to: "9.10E+11" [email protected] Excel Discussion (Misc queries) 2 August 12th 08 03:13 PM
How do I get "auto sum" to subtract hidden cell values from total Marsha Excel Worksheet Functions 3 March 7th 08 05:19 AM
How do I get a column to "auto fill" in a pivot table? punter Excel Discussion (Misc queries) 2 December 8th 05 08:49 PM


All times are GMT +1. The time now is 12:36 AM.

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"