slamet Harto
09-17-2008, 08:53 PM
Hi there,
Can you help to advise me with some checkbox in userform based on option.
Option number1 if checkbox1 value is true then write type with ?CCC?, if Checkbox2 value is true then write ?DDD?, If checkbox3 value is true then write
?EEE? and so on.
In this case, we are allowing the user to choose both of them or all Type.
If all type then, write them all type with ?CCC?, DDD until FFF.
Please advise.
Thanks a bunch.
Rgds, harto
Private Sub CMDButton_Click()
Dim NRowBaru As Integer
If TextBox5.Text = "" Then
MsgBox "please enter firs name!"
TextBox5.SetFocus
Exit Sub
End If
If ComboBox2.Value = "" Then
MsgBox "select the tittle"
ComboBox2.SetFocus
End If
If CheckBox1.Value = False Or CheckBox2.Value = False Or CheckBox3.Value = False Or CheckBox4.Value = False Or CheckBox5.Value = False Then
MsgBox "You must tick at least one of the checkbox"
CheckBox1.SetFocus
CheckBox2.SetFocus
CheckBox3.SetFocus
CheckBox4.SetFocus
CheckBox5.SetFocus
Exit Sub
End If
With Sheets(2)
NRowBaru = WorksheetFunction.CountA(.Range("B:B")) + 4
If CheckBox5.Value = True Then
.Cells(NRowBaru, 1).Value = "CCC"
.Cells(NRowBaru, 2).Value = ComboBox2.Value
.Cells(NRowBaru, 3).Value = TextBox5.Text
.Cells(NRowBaru, 1).Value = TextBox6.Text
NRowBaru = NRowBaru + 1
.Cells(NRowBaru, 1).Value = "DDD"
.Cells(NRowBaru, 2).Value = ComboBox2.Value
.Cells(NRowBaru, 3).Value = TextBox5.Text
.Cells(NRowBaru, 1).Value = TextBox6.Text
NRowBaru = NRowBaru + 1
.Cells(NRowBaru, 1).Value = "EEE"
.Cells(NRowBaru, 2).Value = ComboBox2.Value
.Cells(NRowBaru, 3).Value = TextBox5.Text
.Cells(NRowBaru, 1).Value = TextBox6.Text
NRowBaru = NRowBaru + 1
.Cells(NRowBaru, 1).Value = "FFF"
.Cells(NRowBaru, 2).Value = ComboBox2.Value
.Cells(NRowBaru, 3).Value = TextBox5.Text
.Cells(NRowBaru, 1).Value = TextBox6.Text
ElseIf CheckBox1.Value = True Or CheckBox2.Value = True Then
.Cells(NRowBaru, 1).Value = "CCC"
.Cells(NRowBaru, 2).Value = ComboBox2.Value
.Cells(NRowBaru, 3).Value = TextBox5.Text
.Cells(NRowBaru, 1).Value = TextBox6.Text
NRowBaru = NRowBaru + 1
.Cells(NRowBaru, 1).Value = "DDD"
.Cells(NRowBaru, 2).Value = ComboBox2.Value
.Cells(NRowBaru, 3).Value = TextBox5.Text
.Cells(NRowBaru, 1).Value = TextBox6.Text
ElseIf CheckBox3.Value = True Or CheckBox4.Value = True Then
.Cells(NRowBaru, 1).Value = "EEE"
.Cells(NRowBaru, 2).Value = ComboBox2.Value
.Cells(NRowBaru, 3).Value = TextBox5.Text
.Cells(NRowBaru, 1).Value = TextBox6.Text
NRowBaru = NRowBaru + 1
.Cells(NRowBaru, 1).Value = "FFF"
.Cells(NRowBaru, 2).Value = ComboBox2.Value
.Cells(NRowBaru, 3).Value = TextBox5.Text
.Cells(NRowBaru, 1).Value = TextBox6.Text
Else
.Cells(NRowBaru, 1).Value = CheckBox1
.Cells(NRowBaru, 2).Value = ComboBox2.Value
.Cells(NRowBaru, 3).Value = TextBox5.Text
.Cells(NRowBaru, 1).Value = TextBox6.Text
End If
Call tosetfocus
End With
Range("A4").Select
Unload Me
End Sub
Private Sub togetfocus()
ComboBox2.Value = ""
ComboBox4.Value = ""
TextBox5.Text = ""
TextBox6.Text = ""
End Sub
Can you help to advise me with some checkbox in userform based on option.
Option number1 if checkbox1 value is true then write type with ?CCC?, if Checkbox2 value is true then write ?DDD?, If checkbox3 value is true then write
?EEE? and so on.
In this case, we are allowing the user to choose both of them or all Type.
If all type then, write them all type with ?CCC?, DDD until FFF.
Please advise.
Thanks a bunch.
Rgds, harto
Private Sub CMDButton_Click()
Dim NRowBaru As Integer
If TextBox5.Text = "" Then
MsgBox "please enter firs name!"
TextBox5.SetFocus
Exit Sub
End If
If ComboBox2.Value = "" Then
MsgBox "select the tittle"
ComboBox2.SetFocus
End If
If CheckBox1.Value = False Or CheckBox2.Value = False Or CheckBox3.Value = False Or CheckBox4.Value = False Or CheckBox5.Value = False Then
MsgBox "You must tick at least one of the checkbox"
CheckBox1.SetFocus
CheckBox2.SetFocus
CheckBox3.SetFocus
CheckBox4.SetFocus
CheckBox5.SetFocus
Exit Sub
End If
With Sheets(2)
NRowBaru = WorksheetFunction.CountA(.Range("B:B")) + 4
If CheckBox5.Value = True Then
.Cells(NRowBaru, 1).Value = "CCC"
.Cells(NRowBaru, 2).Value = ComboBox2.Value
.Cells(NRowBaru, 3).Value = TextBox5.Text
.Cells(NRowBaru, 1).Value = TextBox6.Text
NRowBaru = NRowBaru + 1
.Cells(NRowBaru, 1).Value = "DDD"
.Cells(NRowBaru, 2).Value = ComboBox2.Value
.Cells(NRowBaru, 3).Value = TextBox5.Text
.Cells(NRowBaru, 1).Value = TextBox6.Text
NRowBaru = NRowBaru + 1
.Cells(NRowBaru, 1).Value = "EEE"
.Cells(NRowBaru, 2).Value = ComboBox2.Value
.Cells(NRowBaru, 3).Value = TextBox5.Text
.Cells(NRowBaru, 1).Value = TextBox6.Text
NRowBaru = NRowBaru + 1
.Cells(NRowBaru, 1).Value = "FFF"
.Cells(NRowBaru, 2).Value = ComboBox2.Value
.Cells(NRowBaru, 3).Value = TextBox5.Text
.Cells(NRowBaru, 1).Value = TextBox6.Text
ElseIf CheckBox1.Value = True Or CheckBox2.Value = True Then
.Cells(NRowBaru, 1).Value = "CCC"
.Cells(NRowBaru, 2).Value = ComboBox2.Value
.Cells(NRowBaru, 3).Value = TextBox5.Text
.Cells(NRowBaru, 1).Value = TextBox6.Text
NRowBaru = NRowBaru + 1
.Cells(NRowBaru, 1).Value = "DDD"
.Cells(NRowBaru, 2).Value = ComboBox2.Value
.Cells(NRowBaru, 3).Value = TextBox5.Text
.Cells(NRowBaru, 1).Value = TextBox6.Text
ElseIf CheckBox3.Value = True Or CheckBox4.Value = True Then
.Cells(NRowBaru, 1).Value = "EEE"
.Cells(NRowBaru, 2).Value = ComboBox2.Value
.Cells(NRowBaru, 3).Value = TextBox5.Text
.Cells(NRowBaru, 1).Value = TextBox6.Text
NRowBaru = NRowBaru + 1
.Cells(NRowBaru, 1).Value = "FFF"
.Cells(NRowBaru, 2).Value = ComboBox2.Value
.Cells(NRowBaru, 3).Value = TextBox5.Text
.Cells(NRowBaru, 1).Value = TextBox6.Text
Else
.Cells(NRowBaru, 1).Value = CheckBox1
.Cells(NRowBaru, 2).Value = ComboBox2.Value
.Cells(NRowBaru, 3).Value = TextBox5.Text
.Cells(NRowBaru, 1).Value = TextBox6.Text
End If
Call tosetfocus
End With
Range("A4").Select
Unload Me
End Sub
Private Sub togetfocus()
ComboBox2.Value = ""
ComboBox4.Value = ""
TextBox5.Text = ""
TextBox6.Text = ""
End Sub