Toggle Button If Then Statements

Guard913

Board Regular
Joined
Apr 10, 2016
Messages
122
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!!!
 

Some videos you may like

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Watch MrExcel Video

Forum statistics

Threads
1,119,256
Messages
5,577,001
Members
412,760
Latest member
PetterL
Top