hi.
I currently have a excel macro that allows the end user to update the roster based on a single date.
It will have a userform pop out they fill in leave date, first name, leave type. Then click ADD.
This will go to leave the tab and add that information to the next blank row under the 'tblEmployees'
So what I having been trying to work out is how do I do the above but with a range of dates.
IE. 07/10/2022 - 15/10/2022
I have attached 2 images:
- Userform (what end user fills in)
- tblemployees (where it updates)
Below is the code for this:
Private Sub cbbAdd_Click()
Dim LeaveDate As Date
LeaveDate = txtLeaveDate.Text
Dim FirstName As String
FirstName = FirstNameCombo.Text
Dim LeaveType As String
LeaveType = LeaveTypeCombo.Text
Dim wsh As Worksheet
Set wsh = ThisWorkbook.Worksheets("Leave")
Set tbl = wsh.ListObjects("tblEmployees")
Dim lRow As ListRow
Set lRow = tbl.ListRows.Add
With lRow
.Range(1) = LeaveDate
.Range(2) = FirstName
.Range(3) = LeaveType
End With
End Sub
Thank you
Troy