You could use this code:
Private Sub CommandButton1_Click()
Dim irow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
'find first row in database
irow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Range("A" & irow) = TextBox1.Value
.Range("B" & irow) = TextBox2.Value
.Range("C" & irow) = TextBox3.Value
End With
Set ws = Worksheets("Sheet7")
'find first row in database
irow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Range("A" & irow) = TextBox1.Value
.Range("B" & irow) = TextBox2.Value
.Range("C" & irow) = TextBox3.Value
End With
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
End Sub
or also this:
Private Sub CommandButton1_Click()
Dim irow As Long
Dim ws As Worksheet
mySheets = "Sheet1,Sheet7" 'you can also add other sheets...
For Each mySh In Split(mySheets, ",")
With ThisWorkbook.Sheets(mySh)
'find first row in database
irow = .Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
.Range("A" & irow) = TextBox1.Value
.Range("B" & irow) = TextBox2.Value
.Range("C" & irow) = TextBox3.Value
End With
Next mySh
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
End Sub
Regards,
Antonio
Bookmarks