Forum Discussion
sf49ers19238597
Dec 14, 2020Iron Contributor
I have a friend that need help with vab code
need help with part of vba code If Me.cmbWeek.ListIndex > -1 Then
Set Ws = Worksheets(Me.cmbWeek.Value)
Else: MsgBox "INCORRECT INPUT." & vbNewLine & "Use Dropdown For Listed We...
sf49ers19238597
Dec 16, 2020Iron Contributor
The form is for to input data in into worksheet
Date
Description
Withdrawl
Desposit
next for loop
that code i have is in a loop but not working go make work please
HansVogelaar
Dec 16, 2020MVP
You don't want to loop! It makes no sense whatsoever. Try this code:
Private Sub CommandButton1_Click()
Dim r As Long
If Not IsDate(Me.TextBox1) Then
Me.TextBox1.SetFocus
MsgBox "Please enter a valid date!", vbExclamation
Exit Sub
End If
If Me.TextBox2 = "" Then
Me.TextBox2.SetFocus
MsgBox "Please enter a description!", vbExclamation
Exit Sub
End If
If Me.TextBox3 = "" And Me.TextBox4 = "" Then
Me.TextBox3.SetFocus
MsgBox "Please enter a withdrawal and/or a deposit!", vbExclamation
Exit Sub
End If
r = Range("A" & Rows.Count).End(xlUp).Row + 1
Range("A" & r).Value = Me.TextBox1.Value
Range("B" & r).Value = Me.TextBox2.Value
Range("I" & r).Value = Me.TextBox3.Value
Range("J" & r).Value = Me.TextBox4.Value
Unload Me
End Sub- sf49ers19238597Dec 17, 2020Iron Contributor
Thanks You very much the code works good I let my friend later today see he thinks of it