Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default macro to hide # of columns based on value

I am trying to write a macro which will hide certain columns based upon the
value of a cell. For example, if cell value = 1, hide columns A:Q, if value
= 2, hide columns B:Q, if value = 3, hide C:Q and so on. Is there a quick
way of doing this. Thank you.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 364
Default macro to hide # of columns based on value

not much info to work with, i used cell T1 on sheet1 as the value for the
first column

Sub test()
Dim colnum As Long
Dim ws As Worksheet
Set ws = Worksheets("sheet1")
colnum = ws.Range("t1").Value
With ws
.Columns(colnum).Resize(, 18 - colnum).EntireColumn.Hidden = True
End With
End Sub

--


Gary Keramidas


"Graeme" wrote in message
...
I am trying to write a macro which will hide certain columns based upon the
value of a cell. For example, if cell value = 1, hide columns A:Q, if
value
= 2, hide columns B:Q, if value = 3, hide C:Q and so on. Is there a quick
way of doing this. Thank you.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default macro to hide # of columns based on value

Thank you.

"Gary Keramidas" wrote:

not much info to work with, i used cell T1 on sheet1 as the value for the
first column

Sub test()
Dim colnum As Long
Dim ws As Worksheet
Set ws = Worksheets("sheet1")
colnum = ws.Range("t1").Value
With ws
.Columns(colnum).Resize(, 18 - colnum).EntireColumn.Hidden = True
End With
End Sub

--


Gary Keramidas


"Graeme" wrote in message
...
I am trying to write a macro which will hide certain columns based upon the
value of a cell. For example, if cell value = 1, hide columns A:Q, if
value
= 2, hide columns B:Q, if value = 3, hide C:Q and so on. Is there a quick
way of doing this. Thank you.



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
Hide Columns based on a cell value Tami Excel Worksheet Functions 10 July 16th 09 06:31 PM
Writing a macro to hide columns based on cell value JAbels001 Excel Discussion (Misc queries) 2 April 16th 09 05:02 PM
Hide Columns Based on Condition [email protected] Excel Programming 1 July 5th 06 07:40 PM
hide columns based on header macro Todd L. Excel Programming 4 December 7th 04 05:53 PM
Macro to Hide/Show Columns based on control cell value Steve N Excel Programming 2 May 25th 04 06:51 PM


All times are GMT +1. The time now is 02:01 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"