Menu

Rabu, 25 Februari 2015

CARA BUAT CHEKBOX DI FORM EXCEL DAN TOMBOL SIMPANNYA


Private Sub CommandButton1_Click()
Dim str As String
Dim Hom As Long
Hom = Sheet1.Range("A" & Rows.Count).End(xlUp).Row
For Each ctrl In Frame1.Controls
If TypeOf ctrl Is MSForms.CheckBox Then
If ctrl.Value = True Then
Label1.Caption = Label1.Caption & ", " & ctrl.Caption
End If
End If
Next ctrl
Sheet1.Cells(Hom + 1, "A").Value = Right(Label1.Caption, Len(Label1.Caption) - 2)
Label1.Caption = ""
End Sub

Private Sub CommandButton2_Click()
Dim str As String
Dim Hom As Long
Hom = Sheet1.Range("B" & Rows.Count).End(xlUp).Row

If CheckBox1.Value = True Then
str = str & CheckBox1.Caption & ", "
End If
If CheckBox2.Value = True Then
str = str & CheckBox2.Caption & ", "
End If
If CheckBox3.Value = True Then
str = str & CheckBox3.Caption & ", "
End If
If CheckBox4.Value = True Then
str = str & CheckBox4.Caption & ", "
End If
If CheckBox5.Value = True Then
str = str & CheckBox5.Caption & ", "
End If
If CheckBox6.Value = True Then
str = str & CheckBox6.Caption & ", "
End If
If CheckBox7.Value = True Then
str = str & CheckBox7.Caption & ", "
End If
If CheckBox8.Value = True Then
str = str & CheckBox8.Caption & ", "
End If
If CheckBox9.Value = True Then
str = str & CheckBox9.Caption & ", "
End If
If CheckBox10.Value = True Then
str = str & CheckBox10.Caption & ", "
End If

str = Left(str, Len(str) - 2)
Sheet1.Cells(Hom + 1, "B").Value = str

End Sub