LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Simple hiding columns with vba does not work with a checkbox

Hello,

I am a little confused by something that should be very
simple. I am trying to have certain columns hide and
unhide depending on if a check box is check or not checked.
I get an error that says:
"Run-time error 1004"
"Unable to set the Hidden Property of the Range class"

What confuses me most is the following works when placed
in a subroutine but not when placed in a checkbox's change
function.

So this works:

Sub test()
Columns("A:B").Hidden = Not Columns("A:B").Hidden
End Sub

And this doesn't:

Private Sub CheckBox1_Click()
Columns("A:B").Hidden = Not Columns("A:B").Hidden
End Sub

This is all on a blank new workbook with nothing else to
get in the way and I am using Excel 97. The worksheet is
not protected and I get the same results when there is
data in the cells and when there is no date in the cells.
I have also tried included more specific references with
workbooks(). and worksheets(). but that doesn't help
either. Any help would be much appreciated as I am about
to head butt my computer.

Thanks,

Brian
 
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 insert simple checkbox which can be checked by a click? mgreen74 Excel Discussion (Misc queries) 5 August 19th 09 04:31 PM
Inserting a simple checkbox that can be checked Phrank Excel Discussion (Misc queries) 4 May 17th 07 06:02 PM
Hiding a ComboBox with a Checkbox AWeb Excel Worksheet Functions 2 September 15th 06 01:30 PM
Simple Checkbox Message Code nemadrias Excel Discussion (Misc queries) 10 June 21st 06 08:59 PM
I need to create a simple checkbox that has true false outputs RCN Excel Discussion (Misc queries) 1 June 6th 06 08:28 PM


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