Tark221
Registered User.
- Local time
- Today, 23:11
- Joined
- Oct 12, 2012
- Messages
- 74
Just a brief summary:
I have 2 forms:
One form is for adding new staff to a spreadsheet, the form creates a new spreadsheet and renames the sheet based on the staff name - this works fully
The second form is to add absences to a staff member, the problem I'm having is I need the data to input on a sheet based on what staff name is chosen on the drop down box on the form. So say i pick Joe Bloggs when I click submit the absence should be inputted on Joe Bloggs worksheet
Here is some code I've been working with
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("worksheet1")
'find first empty row in database
Dim iRow As Long
iRow = 7
iRow = iRow + 1
'check for a part number
If Trim(Me.TextBox1.Value) = "" Then
Me.TextBox1.SetFocus
MsgBox "Enter details"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.ComboBox1.Value
ws.Cells(iRow, 2).Value = Me.TextBox1.Value
ws.Cells(iRow, 3).Value = Me.TextBox2.Value
ws.Cells(iRow, 4).Value = Me.TextBox6.Value
ws.Cells(iRow, 5).Value = Me.TextBox4.Value
'clear the data
Me.ComboBox1.Value = ""
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.TextBox6.Value = ""
Me.TextBox4.Value = ""
Unload Me
End Sub
Any help would be much appreciated
I have 2 forms:
One form is for adding new staff to a spreadsheet, the form creates a new spreadsheet and renames the sheet based on the staff name - this works fully
The second form is to add absences to a staff member, the problem I'm having is I need the data to input on a sheet based on what staff name is chosen on the drop down box on the form. So say i pick Joe Bloggs when I click submit the absence should be inputted on Joe Bloggs worksheet
Here is some code I've been working with
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("worksheet1")
'find first empty row in database
Dim iRow As Long
iRow = 7
iRow = iRow + 1
'check for a part number
If Trim(Me.TextBox1.Value) = "" Then
Me.TextBox1.SetFocus
MsgBox "Enter details"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.ComboBox1.Value
ws.Cells(iRow, 2).Value = Me.TextBox1.Value
ws.Cells(iRow, 3).Value = Me.TextBox2.Value
ws.Cells(iRow, 4).Value = Me.TextBox6.Value
ws.Cells(iRow, 5).Value = Me.TextBox4.Value
'clear the data
Me.ComboBox1.Value = ""
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.TextBox6.Value = ""
Me.TextBox4.Value = ""
Unload Me
End Sub
Any help would be much appreciated