FROM in EXCEL Using Visual Basic |
CODING FOR SAVE BUTTON
(excel From )
Private Sub CommandButton1_Click()
Dim rowcount As String
rowcount = Worksheets("sheet1").Range("A1").CurrentRegion.Rows.Count
With Range("a1")
.Offset(rowcount, 0).Value = Me.TextBox1.Value
End With
Dim rowcount2 As String
rowcount2 = Worksheets("sheet1").Range("b1").CurrentRegion.Rows.Count
With Range("b1")
.Offset(rowcount, 0).Value = Me.TextBox2.Value
End With
Dim rowcount3 As String
rowcount3 = Worksheets("sheet1").Range("c1").CurrentRegion.Rows.Count
With Range("c1")
.Offset(rowcount, 0).Value = Me.ComboBox1.Value
End With
Dim rowcount4 As String
rowcount4 = Worksheets("sheet1").Range("d1").CurrentRegion.Rows.Count
With Range("d1")
.Offset(rowcount, 0).Value = Me.TextBox3.Value
End With
Dim rowcount5 As String
rowcount5 = Worksheets("sheet1").Range("e1").CurrentRegion.Rows.Count
With Range("e1")
.Offset(rowcount, 0).Value = Me.TextBox4.Value
End With
Dim rowcount6 As String
rowcount6 = Worksheets("sheet1").Range("f1").CurrentRegion.Rows.Count
With Range("f1")
.Offset(rowcount, 0).Value = Me.TextBox5.Value
End With
If Me.TextBox1.Value = "" Then
MsgBox "Fill the Entry!", vbExclamation, "Warning"
Me.TextBox1.SetFocus
Exit Sub
End If
If Me.TextBox2.Value = "" Then
MsgBox "Fill the Entry!", vbExclamation, "Warning"
Me.TextBox2.SetFocus
Exit Sub
End If
If Me.TextBox3.Value = "" Then
MsgBox "Fill the Entry!", vbExclamation, "Warning"
Me.TextBox3.SetFocus
Exit Sub
End If
If Me.TextBox4.Value = "" Then
MsgBox "Fill the Entry!", vbExclamation, "Warning"
Me.TextBox4.SetFocus
Exit Sub
End If
If Me.TextBox5.Value = "" Then
MsgBox "Fill the Entry!", vbExclamation, "Warning"
Me.TextBox5.SetFocus
Exit Sub
End If
If Me.ComboBox1.Value = "" Then
MsgBox "Fill the Entry!", vbExclamation, "Warning"
Me.ComboBox1.SetFocus
Exit Sub
End If
End Sub
cancel button coding
Private Sub CommandButton2_Click()
Unload Me
End Sub
Unload Me
End Sub
No comments:
Post a Comment