CheckBox _ Command Button

L_enfant Du Monde

New Member
Joined
Aug 8, 2016
Messages
31
Hello everybody,

I have lots of data to implement in a file for each row. I am compiling 3 levels of information per lane.
In order to facilitate the implementation of data, I have set command button and check box to hide or filter columns/rows to have a better visual during the input of data.

Is there a way to "secure" the codes ? By secure I mean adding vba to define more properly the code. Hope it's clear...

Below is the different button I have put:

Thank you very much..!


Code:
Code:
Private Sub CheckBox1_Click()     'First check box which hides the lvl2&3 of my data compliation


If CheckBox1.Value = True Then     'Si case à cocher = true (donc est cochée)
CheckBox2.Value = False
CheckBox3.Value = False


   End If
   
       If Range("A1").Value = True Then


    Columns("S:AK").Select
    Selection.EntireColumn.Hidden = True
    Columns("E:R").Select
    Selection.EntireColumn.Hidden = False
    End If
  
    
    Range("B5").Select
    Selection.End(xlDown).Select
  ActiveWindow.ScrollColumn = 5
End Sub


Private Sub CheckBox2_Click()       'Second check box which hides the lvl1&3 of my data compliation


If CheckBox2.Value = True Then 'Si case à cocher = true (donc est cochée)


CheckBox1.Value = False
CheckBox3.Value = False
End If




    
    If Range("A2").Value = True Then
    Columns("O:AB").Select
    Selection.EntireColumn.Hidden = False
    Columns("E:N").Select
    Selection.EntireColumn.Hidden = True
    Columns("AC:AK").Select
    Selection.EntireColumn.Hidden = True
    End If
     
    Range("B5").Select
    Selection.End(xlDown).Select
   ActiveWindow.ScrollColumn = 5
     
End Sub


Private Sub CheckBox3_Click()              'Third check box which hides the lvl1&2 of my data compliation


If CheckBox3.Value = True Then 'Si case à cocher = true (donc est cochée)
CheckBox1.Value = False
CheckBox2.Value = False


End If
    If Range("A3").Value = True Then
    Columns("AB:AK").Select
    Selection.EntireColumn.Hidden = False
    Columns("E:AA").Select
    Selection.EntireColumn.Hidden = True
        Columns("O:R").Select
    Selection.EntireColumn.Hidden = False


End If


       
    Range("B5").Select
    Selection.End(xlDown).Select
  ActiveWindow.ScrollColumn = 5
End Sub


Private Sub CommandButton1_Click()                     'Button to filter on my active accounts where I need to implement data


    ActiveSheet.Range("$C$3:$W$31").AutoFilter Field:=5, Criteria1:="=Yes" _
        , Operator:=xlOr, Criteria2:="=Running"
        
        
End Sub






Private Sub CommandButton2_Click()             'Only a button to remove all filters
  


    ActiveSheet.ShowAllData
    
  
End Sub




Private Sub CommandButton3_Click()           'Below I have 3 buttons for each family I want 


    ActiveSheet.Range("$C$3:$W$31").AutoFilter Field:=3, Criteria1:="=2M" _


End Sub


Private Sub CommandButton4_Click()


    ActiveSheet.Range("$C$3:$W$31").AutoFilter Field:=3, Criteria1:="=Ocean" _
      
End Sub


Private Sub CommandButton5_Click()
    ActiveSheet.Range("$C$3:$W$31").AutoFilter Field:=3, Criteria1:="=The Alliance" _


End Sub


Private Sub CommandButton6_Click()
    ActiveSheet.Range("$A$5:$AK$759").AutoFilter Field:=3


End Sub


Private Sub SpinButton1_Change()
With SpinButton1
    .Min = 0
    .Max = 3
    Range("B1") = .Value
End With


If Range("b1").Value = 1 Then
    ActiveSheet.Range("$C$3:$W$31").AutoFilter Field:=6, Criteria1:="=Round1"
    Range("S3") = "Round 1"
    Range("AF3") = "Round 1"


    End If
    
If Range("b1").Value = 2 Then
    ActiveSheet.Range("$C$3:$W$31").AutoFilter Field:=6, Criteria1:="=Round2"
        Range("S3") = "Round 2"
        Range("AF3") = "Round 2"
    End If
    
If Range("b1").Value = 3 Then
    ActiveSheet.Range("$C$3:$W$31").AutoFilter Field:=6, Criteria1:="=Round3"
        Range("S3") = "Round 3"
        Range("AF3") = "Round 3"
    End If
    
If Range("b1").Value = 0 Then
     ActiveSheet.Range("$C$3:$W$31").AutoFilter Field:=6
          Range("S3") = "All"
         Range("AF3") = "All"
    End If


End Sub
 
Last edited by a moderator:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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