Jimmypop
Well-known Member
- Joined
- Sep 12, 2013
- Messages
- 753
- Office Version
- 365
- Platform
- Windows
Good day again
I have a Userform with 12 Checkboxes on it. I am struggling to get it right with this project. I have done this on a previous project where if value of checkbox is true then it will select a row.
So my issue now, and I don't know what I am doing wrong, is that on Userform when I select Checkbox 1 then it will select the column that I want... However when I select Checkbox 1 and let's say Checkbox 7 then it will only select the column range linked to Checkbox 7 and not Checkbox 1 and 7... I need the end user to select whatever checkbox/s they want and then it needs to select those columns together with "A1:A39". So basically if they select Checkbox1 then it needs to select "A1:A39" together with "B1:B39"... If they select Checkbox1 and Checkbox7 then it needs to select "A1:A39" together with "B1:B39" and "H1:H39" etc...
Here is the code I am using...
I have a Userform with 12 Checkboxes on it. I am struggling to get it right with this project. I have done this on a previous project where if value of checkbox is true then it will select a row.
So my issue now, and I don't know what I am doing wrong, is that on Userform when I select Checkbox 1 then it will select the column that I want... However when I select Checkbox 1 and let's say Checkbox 7 then it will only select the column range linked to Checkbox 7 and not Checkbox 1 and 7... I need the end user to select whatever checkbox/s they want and then it needs to select those columns together with "A1:A39". So basically if they select Checkbox1 then it needs to select "A1:A39" together with "B1:B39"... If they select Checkbox1 and Checkbox7 then it needs to select "A1:A39" together with "B1:B39" and "H1:H39" etc...
Here is the code I am using...
VBA Code:
Private Sub GenerateData_Click()
Range("A1:A39").Select
If Me.Checkbox1.Value = True Then
Range("B1:B39").Select
End If
If Me.Checkbox2.Value = True Then
Range("C1:C39").Select
End If
If Me.Checkbox3.Value = True Then
Range("D1:D39").Select
End If
If Me.Checkbox4.Value = True Then
Range("E1:E39").Select
End If
If Me.Checkbox5.Value = True Then
Range("F1:F39").Select
End If
If Me.Checkbox6.Value = True Then
Range("G1:G39").Select
End If
If Me.Checkbox7.Value = True Then
Range("H1:H39").Select
End If
If Me.Checkbox8.Value = True Then
Range("I1:I39").Select
End If
If Me.Checkbox9.Value = True Then
Range("J1:J39").Select
End If
If Me.Checkbox10.Value = True Then
Range("K1:K39").Select
End If
If Me.Checkbox11.Value = True Then
Range("L1:L39").Select
End If
If Me.Checkbox12.Value = True Then
Range("M1:M39").Select
End If
End Sub