Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Hide / Unhide Columns with checkbox

Hi There,

1. I have a checkbox placed on a sheet -via the Control Toolbox- and
following code for the sheet:

Private Sub CheckBox1_Click()
If CheckBox1 = True Then
Run "GSVHide"
Else
Run "GSVUnHide"
End If
End Sub

2. I have 2 subs under a standard module:

Sub GSVHide()
ActiveSheet.Range("B:B").EntireColumn.Hidden = True
End Sub
Sub GSVUnHide()
ActiveSheet.Range("B:B").EntireColumn.Hidden = False
End Sub

= It Bugs:
Run-time Error 1004:
Unable to set Teh Hidden Propertyof The RAnge Class

- "No" my checkbox is not in a column/ row that is supposed to be
hidden!
- "No" my sheets nor workbook are protected
*? Working in Excel 97 Sr2
*? Is there a problem with my references perhaps?


Any suggestions please Sige

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Hide / Unhide Columns with checkbox

Hi Not much help but your code works fine in xL2002 under XP
I have xL97 under NT in my office I will try it later.


--
Cheers
Nigel



"Sige" wrote in message
oups.com...
Hi There,

1. I have a checkbox placed on a sheet -via the Control Toolbox- and
following code for the sheet:

Private Sub CheckBox1_Click()
If CheckBox1 = True Then
Run "GSVHide"
Else
Run "GSVUnHide"
End If
End Sub

2. I have 2 subs under a standard module:

Sub GSVHide()
ActiveSheet.Range("B:B").EntireColumn.Hidden = True
End Sub
Sub GSVUnHide()
ActiveSheet.Range("B:B").EntireColumn.Hidden = False
End Sub

= It Bugs:
Run-time Error 1004:
Unable to set Teh Hidden Propertyof The RAnge Class

- "No" my checkbox is not in a column/ row that is supposed to be
hidden!
- "No" my sheets nor workbook are protected
*? Working in Excel 97 Sr2
*? Is there a problem with my references perhaps?


Any suggestions please Sige



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Hide / Unhide Columns with checkbox

Sige,

The problem is that the checkbox still has focus. Try


Sub GSVHide()
With ActiveSheet
.Range("A1").Activate
.Range("B:B").EntireColumn.Hidden = True
End With
End Sub
Sub GSVUnHide()
With ActiveSheet
.Range("A1").Activate
.Range("B:B").EntireColumn.Hidden = False
End With
End Sub

--
HTH

Bob Phillips

"Sige" wrote in message
oups.com...
Hi There,

1. I have a checkbox placed on a sheet -via the Control Toolbox- and
following code for the sheet:

Private Sub CheckBox1_Click()
If CheckBox1 = True Then
Run "GSVHide"
Else
Run "GSVUnHide"
End If
End Sub

2. I have 2 subs under a standard module:

Sub GSVHide()
ActiveSheet.Range("B:B").EntireColumn.Hidden = True
End Sub
Sub GSVUnHide()
ActiveSheet.Range("B:B").EntireColumn.Hidden = False
End Sub

= It Bugs:
Run-time Error 1004:
Unable to set Teh Hidden Propertyof The RAnge Class

- "No" my checkbox is not in a column/ row that is supposed to be
hidden!
- "No" my sheets nor workbook are protected
*? Working in Excel 97 Sr2
*? Is there a problem with my references perhaps?


Any suggestions please Sige



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Hide / Unhide Columns with checkbox


Hi Bob,
Thx It works nicely!
-I do not completely understand what the focus on the checkbox has to do
with running the Subs...?
-It aint possible to "un-set" the focus of a control in a different way
than activating another range?

Cheers Sige :o)

"NOSPAM" to be removed for direct mailing...

*** Sent via Developersdex http://www.developersdex.com ***
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Hide / Unhide Columns with checkbox

Sige,

It is a bug, so logic doesn't come into it :-).

You could activate the activecell (honest) so as not to select another
range, like so

Sub GSVHide()
With ActiveSheet
ActiveCell.Activate
.Range("B:B").EntireColumn.Hidden = True
End With
End Sub
Sub GSVUnHide()
With ActiveSheet
ActiveCell.Activate
.Range("B:B").EntireColumn.Hidden = False
End With
End Sub

--
HTH

Bob Phillips

"SIGE" wrote in message
...

Hi Bob,
Thx It works nicely!
-I do not completely understand what the focus on the checkbox has to do
with running the Subs...?
-It aint possible to "un-set" the focus of a control in a different way
than activating another range?

Cheers Sige :o)

"NOSPAM" to be removed for direct mailing...

*** Sent via Developersdex http://www.developersdex.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
How Unhide & Hide Columns with VBA jean Excel Discussion (Misc queries) 1 June 17th 09 02:03 AM
Hide/Unhide columns using button on top over relevant columns [email protected] Excel Discussion (Misc queries) 1 March 7th 07 09:24 PM
hide or unhide pivotfield using a checkbox Richard[_33_] Excel Programming 0 February 10th 05 12:02 PM
Checkbox to hide and unhide rows Please. Steved Excel Worksheet Functions 2 December 6th 04 11:30 PM
Checkbox Control to Hide/Unhide Worksheet Peter[_29_] Excel Programming 2 October 24th 03 05:00 PM


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