Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default hiding showing columns using checkboxes

Hoping someone can help - I'm sure this is simple - I just can't get i
to work

I have 2 checkboxes to show and hide information - from browsing thi
forum I have come up with the following:

Private Sub CheckBox1_Click()
Dim r As Range
Set r = Range("G1:H1")
r.EntireColumn.Hidden = Not r.EntireColumn.Hidden
End Sub

Private Sub CheckBox2_Click()
Dim r As Range
Set r = Range("M1:AM1")
r.EntireColumn.Hidden = Not r.EntireColumn.Hidden
End Sub

Both of these work fine idependently - however when I check one and no
the other sometimes it works and sometimes it doesn't.

What I am looking to do is the following
if cbox1 is true and cbox2 is true it needs to show columns a-l,an-aw
if cbox1 is false and cbox2 is true it needs to show column
a-f,j-l,an-ap
if cbox1 is true and cbox2 is false it needs to show everything
if cbox 1 is false and cbox2 is false it needs to show column
a-f,j-o,r-x,aa-ag,aj-ap

I have tried various if/then statements but the results still are no
consistent
any suggestions are appreciate

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default hiding showing columns using checkboxes

Ronda,

It seems to me that you need more checkboxes to get the all the combos
you've specified here. I don't see how you can get your last set of columns
(both boxes false) with just the ranges you've specified. Other than that,
I think the code below might give you more consistent results because
checked will always mean hidden:

Private Sub CheckBox1_Click()
Dim r As Range
Set r = Range("G1:H1")
r.EntireColumn.Hidden = CheckBox1
End Sub

Private Sub CheckBox2_Click()
Dim r As Range
Set r = Range("M1:AM1")
r.EntireColumn.Hidden = CheckBox2
End Sub

hth,

Doug Glancy

"ronda " wrote in message
...
Hoping someone can help - I'm sure this is simple - I just can't get it
to work

I have 2 checkboxes to show and hide information - from browsing this
forum I have come up with the following:

Private Sub CheckBox1_Click()
Dim r As Range
Set r = Range("G1:H1")
r.EntireColumn.Hidden = Not r.EntireColumn.Hidden
End Sub

Private Sub CheckBox2_Click()
Dim r As Range
Set r = Range("M1:AM1")
r.EntireColumn.Hidden = Not r.EntireColumn.Hidden
End Sub

Both of these work fine idependently - however when I check one and not
the other sometimes it works and sometimes it doesn't.

What I am looking to do is the following
if cbox1 is true and cbox2 is true it needs to show columns a-l,an-aw
if cbox1 is false and cbox2 is true it needs to show columns
a-f,j-l,an-ap
if cbox1 is true and cbox2 is false it needs to show everything
if cbox 1 is false and cbox2 is false it needs to show columns
a-f,j-o,r-x,aa-ag,aj-ap

I have tried various if/then statements but the results still are not
consistent
any suggestions are appreciated


---
Message posted from http://www.ExcelForum.com/



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 showing and hiding detail KC Excel Discussion (Misc queries) 1 October 20th 09 07:56 PM
need code for hiding/unhiding sheets using checkboxes pzx8hf Excel Worksheet Functions 1 August 13th 08 12:11 AM
Hiding Control Toolbar Checkboxes Ellen G Excel Discussion (Misc queries) 2 September 24th 07 09:59 PM
Hiding Rows with Checkboxes Ellen G Excel Discussion (Misc queries) 1 April 6th 07 08:00 PM
hiding and showing graphs chrisrowe_cr Excel Worksheet Functions 0 September 2nd 05 11:22 AM


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