Not all of the column headers appear to align with the fields in the Userform but I am sure that the following code will give you the idea of how to achieve your results.
Copy the following UDF (User Defined Function) into your standard Module1. This UDF is called to find the last used row of a range (In your case columns A to J) in the Data sheet and then the code adds 1 for the next blank row.
Function LastRowOrCol(bolRowOrCol As Boolean, Optional rng As Range) As Long
'Finds the last used row or column in a worksheet
'First parameter is True for Last Row or False for last Column
'Third parameter is optional
'Must be specified if not ActiveSheet
Dim lngRowCol As Long
Dim rngToFind As Range
If rng Is Nothing Then
Set rng = ActiveSheet.Cells
End If
If bolRowOrCol Then
lngRowCol = xlByRows
Else
lngRowCol = xlByColumns
End If
With rng
Set rngToFind = rng.Find(What:="*", _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=lngRowCol, _
SearchDirection:=xlPrevious, _
MatchCase:=False)
End With
If Not rngToFind Is Nothing Then
If bolRowOrCol Then
LastRowOrCol = rngToFind.Row
Else
LastRowOrCol = rngToFind.Column
End If
End If
End Function
Copy the following code into the Userform Module.
Private Sub CommandButton1_Click()
Dim wsData As Worksheet
Dim r As Long
Set ws = Worksheets("Data") 'Assign worksheet name to a worksheet variable
'Because "With ws" is used prefix all cells with dot as follows
'otherwise requires ws.cells(r, "C") etc
With ws
r = LastRowOrCol(True, .Columns("A:J")) + 1
.Cells(r, "B") = Time() 'Time stamp
.Cells(r, "C") = DateValue(Me.listDate.Value) 'Converts text in the Userform to date format
.Cells(r, "D") = Me.listDepartment.Value
.Cells(r, "E") = Me.listEmployeeNo.Value
.Cells(r, "F") = Me.listEmployee.Value
.Cells(r, "G") = Me.listProjectName.Value
.Cells(r, "I") = Me.listTask1.Value
.Cells(r, "J") = Me.listHours.Value
End With
End Sub
Feel free to get back to me with any problems. However, it will be tomorrow before I get back to you again because it is approaching bed time in my part of the world.