程式碼2
Private Sub CommandAdd_Click() Dim sh As Worksheet Set sh = ThisWorkbook.Sheets("Sheet1") Dim n As Long n = sh.Range("A" & Application.Rows.Count).End(xlUp).Row If VBA.IsNumeric(Me.TextBox.Value) = False Then MsgBox "Number only" Exit Sub End If If Me.Object.Value = "" Then MsgBox "information" Exit Sub End If If Me.CheckBox1.Value = True/False And Me.CheckBox2.Value = True/False And Me.CheckBox3.Value = True/False Then MsgBox "information" Exit Sub End If sh.Range("A" & n+1).Value = Me.TextBox.Value If Me.OptionButton1.Value = True Then sh.Range("C" & n+1).Value = "Man" If Me.OptionButton2.Value = True Then sh.Range("C" & n+1).Value = "Woman" If Me.CheckBox1.Value = True Then sh.Range("D" & n+1).Value = "X" If Me.CheckBox2.Value = True Then sh.Range("D" & n+1).Value = "Y" If Me.CheckBox3.Value = True Then sh.Range("D" & n+1).Value = "X" sh.Range("E" & n+1).Value = Me.ComboBox2.Value If Application.WorksheetFunction.CountIf(sh.Range("A:A"), Me.TextBox1.Value) > 0 Then MsgBox "already exist", vbCritical Exit Sub End If End Sub = = = = = = = = = = Private Sub CommandClear_Click() Me.object.Value = "" or False End Sub = = = = = = = = = = Private Sub UserForm_Activate() With Me.ComboBox2 .Clear .AddItem "" End With End Sub
沒有留言:
張貼留言