Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
Run VBA code only worksheet change, but don't trigger worksheet_change event based on what the code does | Excel Programming | |||
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. | Excel Programming | |||
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... | Excel Programming | |||
Excel code convert to Access code - Concat & eliminate duplicates | Excel Programming |