I'm new to vba and need help with a vba script. I have two command buttons that were created within a UserForm1. I've tried to run the second by using "Call", but it does not work. Is there a way to run button 1 first, then button 2 immediately after 1?
Public Sub CommandButton1_Click()
Dim LastRow As Long, ws As Worksheet
Set ws = Sheets("CIF")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row + 1
ws.Range("A" & LastRow).Value = TextBox1.Text
Public Sub CommandButton2_Click()
Dim i As Long, LastRow As Long, ws As Worksheet
Set ws = Sheets("CIF")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If (Me.TextBox1.Text) = ws.Cells(i, "A") Then
Me.TextBox2 = ws.Cells(i, "B").Value
End Sub
Public Sub CommandButton2_Click()
Dim i As Long, LastRow As Long, ws As Worksheet
Set ws = Sheets("CIF")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If (Me.TextBox1.Text) = ws.Cells(i, "A") Then
Me.TextBox2 = ws.Cells(i, "B").Value
End If
Next i
End Sub
Public Sub CommandButton1_Click()
Dim LastRow As Long, ws As Worksheet
Set ws = Sheets("CIF")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row + 1
ws.Range("A" & LastRow).Value = TextBox1.Text
Public Sub CommandButton2_Click()
Dim i As Long, LastRow As Long, ws As Worksheet
Set ws = Sheets("CIF")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If (Me.TextBox1.Text) = ws.Cells(i, "A") Then
Me.TextBox2 = ws.Cells(i, "B").Value
End Sub
Public Sub CommandButton2_Click()
Dim i As Long, LastRow As Long, ws As Worksheet
Set ws = Sheets("CIF")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If (Me.TextBox1.Text) = ws.Cells(i, "A") Then
Me.TextBox2 = ws.Cells(i, "B").Value
End If
Next i
End Sub