pvzshark
02-26-2020, 02:20 AM
I have 4 buttons - 2017 to 2020
then 12 buttons jan to desember.
When you click 2017 then i hide all cells that is in that range. the same for 2018 etc
then if you do not want to see jan you can click on jan then it should take jan away, but because the trigger is at hide and you click jan then the jan 2017 becomes unhidded as the 2017 has hidden it.
I have tried to fix it with this iff then statement but now it only reads the first iff statement. please help
Private Sub b2017_Click()
Range("EE2").Value = (Range("EE2").Value + 1) Mod 1
Me.OLEObjects(1).Object.Caption = IIf(Range("EE2").Value = 0, "20170", "2017a")
Set xAddress = Range("C:C,H:H,M:M,R:R,W:W,AB:AB,AG:AG,AL:AL,AQ:AQ,AV:AV,BA:BA,BF:BF,BK:BK,BQ:BQ")
If xAddress.EntireColumn.Hidden = True Then
xAddress.EntireColumn.Hidden = False
Else
xAddress.EntireColumn.Hidden = True
End If
End Sub
Private Sub ToggleButton1_Click()
Range("EF2").Value = (Range("EF2").Value + 1) Mod 1
Me.OLEObjects(16).Object.Caption = IIf(Range("EF2").Value = 0, "20180", "2018a")
Set xAddress = Range("D:D,I:I,N:N,S:S,X:X,AC:AC,AH:AH,AM:AM,AR:AR,AW:AW,BB:BB,BG:BG,BL:BL,BR:BR")
If xAddress.EntireColumn.Hidden = True Then
xAddress.EntireColumn.Hidden = False
Else
xAddress.EntireColumn.Hidden = True
End If
End Sub
Private Sub ToggleButton2_Click()
Range("EG2").Value = (Range("EG2").Value + 1) Mod 1
Me.OLEObjects(2).Object.Caption = IIf(Range("EG2").Value = 0, "20190", "2019a")
Set xAddress = Range("E:E,J:J,O:O,T:T,Y:Y,AD:AD,AI:AI,AN:AN,AS:AS,AX:AX,BC:BC,BH:BH,BM:BM")
If xAddress.EntireColumn.Hidden = True Then
xAddress.EntireColumn.Hidden = False
Else
xAddress.EntireColumn.Hidden = True
End If
End Sub
Private Sub ToggleButton3_Click()
Range("EH2").Value = (Range("EH2").Value + 1) Mod 1
Me.OLEObjects(3).Object.Caption = IIf(Range("EH2").Value = 0, "20200", "2020a")
Set xAddress = Range("F:F,K:K,P:P,U:U,Z:Z,AE:AE,AT:AT,AJ:AJ,AO:AO,AT:AT,AY:AY,BD:BD,BI:BI,BN:BN")
If xAddress.EntireColumn.Hidden = True Then
xAddress.EntireColumn.Hidden = False
Else
xAddress.EntireColumn.Hidden = True
End If
End Sub
Private Sub ToggleButton4_Click()
Range("EI2").Value = (Range("EI2").Value + 1) Mod 1
Me.OLEObjects(4).Object.Caption = IIf(Range("EI2").Value = 0, "JAN0", "JANa")
Set xAddress = Range("C:C,D:D,E:E,F:F,g:g")
Set a7Address = Range("C:C")
Set a8Address = Range("D:D")
Set a9Address = Range("E:E")
Set a10Address = Range("F:F")
If Range("ee2") = "0" And Range("ei2") = "1" Then
a8Address.EntireColumn.Hidden = True
ElseIf Range("ef2") = "0" And Range("ei2") = "1" Then
a7Address.EntireColumn.Hidden = True
ElseIf Range("eg2") = "0" And Range("ei2") = "1" Then
a9Address.EntireColumn.Hidden = True
ElseIf Range("eh2") = "0" And Range("ei2") = "1" Then
a10Address.EntireColumn.Hidden = True
ElseIf Range("ee2") = "1" And Range("ei2") = "1" Then
a7Address.EntireColumn.Hidden = True
ElseIf Range("ef2") = "1" And Range("ei2") = "1" Then
a8Address.EntireColumn.Hidden = True
ElseIf Range("eg2") = "1" And Range("ei2") = "1" Then
a9Address.EntireColumn.Hidden = True
ElseIf Range("eh2") = "1" And Range("ei2") = "1" Then
a10Address.EntireColumn.Hidden = True
ElseIf Range("ee2") = "1" And Range("ei2") = "0" Then
a7Address.EntireColumn.Hidden = True
ElseIf Range("ef2") = "1" And Range("ei2") = "0" Then
a8Address.EntireColumn.Hidden = True
ElseIf Range("eg2") = "1" And Range("ei2") = "0" Then
a9Address.EntireColumn.Hidden = True
ElseIf Range("eh2") = "1" And Range("ei2") = "0" Then
a10Address.EntireColumn.Hidden = True
ElseIf Range("ee2") = "0" And Range("ei2") = "0" Then
a7Address.EntireColumn.Hidden = False
ElseIf Range("ef2") = "0" And Range("ei2") = "0" Then
a8Address.EntireColumn.Hidden = False
ElseIf Range("eg2") = "0" And Range("ei2") = "0" Then
a9Address.EntireColumn.Hidden = False
Else
xAddress.EntireColumn.Hidden = True
End If
End Sub
then 12 buttons jan to desember.
When you click 2017 then i hide all cells that is in that range. the same for 2018 etc
then if you do not want to see jan you can click on jan then it should take jan away, but because the trigger is at hide and you click jan then the jan 2017 becomes unhidded as the 2017 has hidden it.
I have tried to fix it with this iff then statement but now it only reads the first iff statement. please help
Private Sub b2017_Click()
Range("EE2").Value = (Range("EE2").Value + 1) Mod 1
Me.OLEObjects(1).Object.Caption = IIf(Range("EE2").Value = 0, "20170", "2017a")
Set xAddress = Range("C:C,H:H,M:M,R:R,W:W,AB:AB,AG:AG,AL:AL,AQ:AQ,AV:AV,BA:BA,BF:BF,BK:BK,BQ:BQ")
If xAddress.EntireColumn.Hidden = True Then
xAddress.EntireColumn.Hidden = False
Else
xAddress.EntireColumn.Hidden = True
End If
End Sub
Private Sub ToggleButton1_Click()
Range("EF2").Value = (Range("EF2").Value + 1) Mod 1
Me.OLEObjects(16).Object.Caption = IIf(Range("EF2").Value = 0, "20180", "2018a")
Set xAddress = Range("D:D,I:I,N:N,S:S,X:X,AC:AC,AH:AH,AM:AM,AR:AR,AW:AW,BB:BB,BG:BG,BL:BL,BR:BR")
If xAddress.EntireColumn.Hidden = True Then
xAddress.EntireColumn.Hidden = False
Else
xAddress.EntireColumn.Hidden = True
End If
End Sub
Private Sub ToggleButton2_Click()
Range("EG2").Value = (Range("EG2").Value + 1) Mod 1
Me.OLEObjects(2).Object.Caption = IIf(Range("EG2").Value = 0, "20190", "2019a")
Set xAddress = Range("E:E,J:J,O:O,T:T,Y:Y,AD:AD,AI:AI,AN:AN,AS:AS,AX:AX,BC:BC,BH:BH,BM:BM")
If xAddress.EntireColumn.Hidden = True Then
xAddress.EntireColumn.Hidden = False
Else
xAddress.EntireColumn.Hidden = True
End If
End Sub
Private Sub ToggleButton3_Click()
Range("EH2").Value = (Range("EH2").Value + 1) Mod 1
Me.OLEObjects(3).Object.Caption = IIf(Range("EH2").Value = 0, "20200", "2020a")
Set xAddress = Range("F:F,K:K,P:P,U:U,Z:Z,AE:AE,AT:AT,AJ:AJ,AO:AO,AT:AT,AY:AY,BD:BD,BI:BI,BN:BN")
If xAddress.EntireColumn.Hidden = True Then
xAddress.EntireColumn.Hidden = False
Else
xAddress.EntireColumn.Hidden = True
End If
End Sub
Private Sub ToggleButton4_Click()
Range("EI2").Value = (Range("EI2").Value + 1) Mod 1
Me.OLEObjects(4).Object.Caption = IIf(Range("EI2").Value = 0, "JAN0", "JANa")
Set xAddress = Range("C:C,D:D,E:E,F:F,g:g")
Set a7Address = Range("C:C")
Set a8Address = Range("D:D")
Set a9Address = Range("E:E")
Set a10Address = Range("F:F")
If Range("ee2") = "0" And Range("ei2") = "1" Then
a8Address.EntireColumn.Hidden = True
ElseIf Range("ef2") = "0" And Range("ei2") = "1" Then
a7Address.EntireColumn.Hidden = True
ElseIf Range("eg2") = "0" And Range("ei2") = "1" Then
a9Address.EntireColumn.Hidden = True
ElseIf Range("eh2") = "0" And Range("ei2") = "1" Then
a10Address.EntireColumn.Hidden = True
ElseIf Range("ee2") = "1" And Range("ei2") = "1" Then
a7Address.EntireColumn.Hidden = True
ElseIf Range("ef2") = "1" And Range("ei2") = "1" Then
a8Address.EntireColumn.Hidden = True
ElseIf Range("eg2") = "1" And Range("ei2") = "1" Then
a9Address.EntireColumn.Hidden = True
ElseIf Range("eh2") = "1" And Range("ei2") = "1" Then
a10Address.EntireColumn.Hidden = True
ElseIf Range("ee2") = "1" And Range("ei2") = "0" Then
a7Address.EntireColumn.Hidden = True
ElseIf Range("ef2") = "1" And Range("ei2") = "0" Then
a8Address.EntireColumn.Hidden = True
ElseIf Range("eg2") = "1" And Range("ei2") = "0" Then
a9Address.EntireColumn.Hidden = True
ElseIf Range("eh2") = "1" And Range("ei2") = "0" Then
a10Address.EntireColumn.Hidden = True
ElseIf Range("ee2") = "0" And Range("ei2") = "0" Then
a7Address.EntireColumn.Hidden = False
ElseIf Range("ef2") = "0" And Range("ei2") = "0" Then
a8Address.EntireColumn.Hidden = False
ElseIf Range("eg2") = "0" And Range("ei2") = "0" Then
a9Address.EntireColumn.Hidden = False
Else
xAddress.EntireColumn.Hidden = True
End If
End Sub