Call Private Sub ToggleButton1_Click()

Mindlesh

Board Regular
Joined
Apr 2, 2014
Messages
172
When I call ToggleButton1_Click, why are the columns not toggled in the way that they are when I click the button?
Code:
Private Sub ToggleButton1_Click()
    With ActiveSheet.ListObjects("Table4")
        .ListColumns("Ti").DataBodyRange.EntireColumn.Hidden = Not (ToggleButton1.Value)
        .ListColumns("Ne").DataBodyRange.EntireColumn.Hidden = Not (ToggleButton1.Value)
    End With
End Sub

Private Sub CommandButton1_Click()
    Application.Run "Sheet8.ToggleButton1_Click"
End Sub
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
you should need at most (providing the right sheet is selected, or there is only one toggle named the same)

Private Sub CommandButton1_Click()
ToggleButton1_Click
End Sub
 
Upvote 0
I have selected the right sheet number, and there is only one toggle. I have tested that ToggleButton1_Click is being called by alternating the button's caption, but still the columns are unaffected.
 
Upvote 0
If you F8 can you follow the code following what you what when triggered
 
Upvote 0
so where in
Code:
Private Sub ToggleButton1_Click()
    With ActiveSheet.ListObjects("Table4")
        .ListColumns("Ti").DataBodyRange.EntireColumn.Hidden = Not (ToggleButton1.Value)
        .ListColumns("Ne").DataBodyRange.EntireColumn.Hidden = Not (ToggleButton1.Value)
    End With
End Sub
does it fail
 
Upvote 0
So it runs to the End Sub, but no action occurs, that what is established. Can you post a workbook somewhere that can be looked at (stripped down data). Need to test whats happening
 
Upvote 0
I created a separate workbook, and it has yielded error 91: Object variable or With block variable not set. What do I need to do differently?
 
Upvote 0
Using my vast guessing without seeing the problem skills, I would start by placing Option Explict at the very top of the code, so when you compile it will show errors
 
Upvote 0

Forum statistics

Threads
1,214,400
Messages
6,119,284
Members
448,885
Latest member
LokiSonic

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top