Code to minimaze workbook and read checkbox value from worksheet

jaryszek

Board Regular
Joined
Jul 1, 2016
Messages
213
Hi,

cross posted here:
Code to find out value in checkbox when workbook is minimazed

MY code is:
VBA Code:
Private Sub Workbook_WindowResize(ByVal Wn As Window)

    Dim CheckBox1 As CheckBox
    
    Set CheckBox1 = ActiveSheet.CheckBoxes("Check Box 1")
    Dim ValChcBox As String
    
    ValChcBox = CheckBox1.Value

    If Wn.WindowState = xlMaximized Then
    ElseIf Wn.WindowState = xlMinimized Then
            If ValChcBox = xlOn Then
                If Not UserForm1.Visible Then UserForm1.Show vbModeless
            End If
    
    Else ' normal
    End If

End Sub

is is possible to catch value of checbox before resizing workbook event?

Jacek
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
You could create a public variable to store the state of the checkbox & whenever the checkbox is clicked update that value.
 
Upvote 0
thank you!

Ooo so it would work after clicking and storing variable even if macro was finished?
How long public variable is kept in memory?

Jacek
 
Upvote 0
It will be kept in memory until the workbook is closed.
 
Upvote 0
Hello,

i tried to put code like here in worksheet where i have Checkbox1:

VBA Code:
Public IsEnabled As Boolean

Public Sub CheckBox1_Click()

If TimerWsh.CheckBox1.Value = True Then
    CheckBox1.Caption = "Disable Sound for Timer"
    IsEnabled = True
Else
    TimerWsh.CheckBox1.Caption = "Enable Sound for Timer"
    IsEnabled = False
End If

End Sub

And now in module (after clicking checkbox):

Code:
sub test 

debug.print isEnabled

end sub

but i have that variable is not find.
Why?
How to do this working?

Jacek
 
Upvote 0
You need to declare the variable in a standard module & not in the userform module.
 
Upvote 0

Forum statistics

Threads
1,214,981
Messages
6,122,565
Members
449,089
Latest member
Motoracer88

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