This ought t be quite straightforward but I must be looking for the wrong information on the Internet.
I will be using a number of User Forms to display information and need to be able to user a separate User Form to upload and update details through a single worksheet.
Recalling informtion is not a problem, however, I need the correct syntax to upload information to a specific worksheet whilst having command buttons for all the user forms on a single separate worksheet.
I am sure that I just need to "activate" the target ws
Sample Code
Note I have yet to determine if
'Cells(lastrow + 1, "A").Value = TextBox1
needs to be included.
Hoping someone can assist
I will be using a number of User Forms to display information and need to be able to user a separate User Form to upload and update details through a single worksheet.
Recalling informtion is not a problem, however, I need the correct syntax to upload information to a specific worksheet whilst having command buttons for all the user forms on a single separate worksheet.
I am sure that I just need to "activate" the target ws
Sample Code
VBA Code:
Private Sub cmdAddRecord_Click()
'Used to add new records to the database
Dim lastrow As Long
Dim TextA As String
TextA = TextBox3
If Application.WorksheetFunction.CountIf(Sheets("Worksheet2").Range("C5:C70"), TextA) > 0 Then
MsgBox "Texta already exists", 0, "Duplication Check"
Call UserForm_Initialize
txtTextBox2.SetFocus
Exit Sub
End If
lastrow = Sheets("Worksheet2").Range("B" & Rows.Count).End(xlUp).Row
'Cells(lastrow + 1, "A").Value = TextBox1
Cells(lastrow + 1, "B").Value = TextBox2
Cells(lastrow + 1, "C").Value = TextBox3
Cells(lastrow + 1, "D").Value = TextBox4
MsgBox TextBox3 & " has been added to the database", 0, "Record Added"
Call UserForm_Initialize
txtTextBox2.SetFocus
End Sub
Note I have yet to determine if
'Cells(lastrow + 1, "A").Value = TextBox1
needs to be included.
Hoping someone can assist