Toggle Button If Then Statements

Guard913

Board Regular
Joined
Apr 10, 2016
Messages
144
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
What I am trying to do is, If 2 Forms are showing, and I toggle 1 button to hide 1 form then the other form moves up, and if I bring the other form back then it will push other form back down.

*Main Command Post* <-- This is a Userform with 4 Toggle Buttons However 3&4 are the same size and 3 will never be visible if 4 is visible and vice versa.

*Main Command Post*
1
2
3/4

(1 Is Gone)
*Main Command Post*
2
3/4
Blank

(2 Is Gone)
*Main Command Post*
1
3/4
Blank

(3/4 Is Gone)
*Main Command Post*
1
2
Blank

(1 & 3/4 Is Gone)
*Main Command Post*
2
Blank
Blank

(2 & 3/4 Is Gone)
*Main Command Post*
1
Blank
Blank

Copy of code so far of trying this, and failing.... Edited to have numbers instead of form name. If you can show how to do just 1 button correctly I can do the rest myself most likely.

VBA Code:
Private Sub ToggleButton4_Click()
If ToggleButton4.Value = True Then
ToggleButton4.BackColor = RGB(0, 255, 0)
1.Show
1.StartUpPosition = 0
1.Left = Command_Post.Left - 0
1.Top = Command_Post.Top + 70
ToggleButton4.Caption = "Hide 1"

Else

If ToggleButton1.Value = True Then
2.Show
2.StartUpPosition = 0
2.Left = Command_Post.Left - 0
2.Top = Command_Post.Top + 70
ToggleButton4.BackColor = RGB(240, 240, 240)
Caller_Form.Hide
ToggleButton4.Caption = "Show 1"

Else

If ToggleButton4.Value = False And ToggleButton1.Value = False Then

ToggleButton4.BackColor = RGB(240, 240, 240)
1.Hide
ToggleButton4.Caption = "Show 1"

End If
End Sub


Thanks!!!
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,215,540
Messages
6,125,409
Members
449,223
Latest member
Narrian

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