#1   Report Post  
Posted to microsoft.public.excel.programming
tom tom is offline
external usenet poster
 
Posts: 570
Default VB code

Good day.

I have created check boxes that control hiding and unhiding columns and rows
in one workbook writing the following code to control the hiding and unhiding.

Private Sub Worksheet_Calculate()

If Range("b5").Value = False Then
Columns("c:p").EntireColumn.Hidden = True
Else
Columns("c:p").EntireColumn.Hidden = False
End If

End Sub

I have since opened a new workbook, created another checkbox and used the
same code with absolutely no luck. I have checked my Macro settings in both,
which are both set to "low".

I am completely baffled.

Any suggestions?
--
Tom
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default VB code

hi
you might have better luck putting the code in the check box itself. here is
an example some old code i wrote several years ago to hide/unhide
metric/english measurments.
Private Sub ChBx1_Click()
If Columns("C:C").Hidden = True Then
Columns("C:C").Hidden = False
ChBx1.BackColor = RGB(0, 0, 255)
ChBx1.ForeColor = RGB(245, 245, 5)
ChBx1.Caption = "Metric"
Columns("D:D").Hidden = True
Else
Columns("C:C").Hidden = True
Columns("D:D").Hidden = False
ChBx1.BackColor = RGB(245, 30, 5)
'ChBx1.ForeColor =
ChBx1.Caption = "English"
End If
End Sub
I not only hid and unhide the columns, i also change the back color, text
color and captions.

worked great just by clicking.

Regards,
FSt1
"tom" wrote:

Good day.

I have created check boxes that control hiding and unhiding columns and rows
in one workbook writing the following code to control the hiding and unhiding.

Private Sub Worksheet_Calculate()

If Range("b5").Value = False Then
Columns("c:p").EntireColumn.Hidden = True
Else
Columns("c:p").EntireColumn.Hidden = False
End If

End Sub

I have since opened a new workbook, created another checkbox and used the
same code with absolutely no luck. I have checked my Macro settings in both,
which are both set to "low".

I am completely baffled.

Any suggestions?
--
Tom

  #3   Report Post  
Posted to microsoft.public.excel.programming
tom tom is offline
external usenet poster
 
Posts: 570
Default VB code

Still no luck.

My code works in a seperate workbook I was working on yesterday and not in
the one I'm working on today.??
--
Tom


"FSt1" wrote:

hi
you might have better luck putting the code in the check box itself. here is
an example some old code i wrote several years ago to hide/unhide
metric/english measurments.
Private Sub ChBx1_Click()
If Columns("C:C").Hidden = True Then
Columns("C:C").Hidden = False
ChBx1.BackColor = RGB(0, 0, 255)
ChBx1.ForeColor = RGB(245, 245, 5)
ChBx1.Caption = "Metric"
Columns("D:D").Hidden = True
Else
Columns("C:C").Hidden = True
Columns("D:D").Hidden = False
ChBx1.BackColor = RGB(245, 30, 5)
'ChBx1.ForeColor =
ChBx1.Caption = "English"
End If
End Sub
I not only hid and unhide the columns, i also change the back color, text
color and captions.

worked great just by clicking.

Regards,
FSt1
"tom" wrote:

Good day.

I have created check boxes that control hiding and unhiding columns and rows
in one workbook writing the following code to control the hiding and unhiding.

Private Sub Worksheet_Calculate()

If Range("b5").Value = False Then
Columns("c:p").EntireColumn.Hidden = True
Else
Columns("c:p").EntireColumn.Hidden = False
End If

End Sub

I have since opened a new workbook, created another checkbox and used the
same code with absolutely no luck. I have checked my Macro settings in both,
which are both set to "low".

I am completely baffled.

Any suggestions?
--
Tom

  #4   Report Post  
Posted to microsoft.public.excel.programming
tom tom is offline
external usenet poster
 
Posts: 570
Default VB Code

I have also found that I am able to run the code with success from within my VB
code window.

Must be some minor glitch regarding allowing the checkbox to perform it's
duty.

Tom
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default VB Code

hi
sorry to take so long to get back. got hung up.
question. Why did you tie your code and the hiding and unhiding of columns
to the calculation event.? that confused me. am i missing something?
the calculation event is triggered by enter, paste, delete, F9, and others
which seemed random to me. you say that it works for you. could you explain
further.....please.
regards
FST1



"tom" wrote:

I have also found that I am able to run the code with success from within my VB
code window.

Must be some minor glitch regarding allowing the checkbox to perform it's
duty.

Tom

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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Run VBA code only worksheet change, but don't trigger worksheet_change event based on what the code does ker_01 Excel Programming 6 October 3rd 08 09:45 PM
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. Corey Excel Programming 3 December 11th 06 05:14 AM
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM


All times are GMT +1. The time now is 12:04 PM.

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"