Hey All
I have the bellow code which takes the inputted start and end date along with the other inputted fields and and lists them besides each individual date within that range on a table in a different sheet.
The issue is that this will list every single date within the range, However I want it to only list the weekdays and not the weekends (Sat and Sun). Any help would be greatly appreciated.
Private Sub cbInputleave_Click()
Dim FirstDate As Date, LastDate As Date
Dim rBlanks As Range
Dim ssheet As Worksheet
Dim ctl As Control
Set ssheet = ThisWorkbook.Sheets("Mark Leave")
FirstDate = tbstartdate.Value
LastDate = tbenddate.Value
With ssheet.Range("D" & Rows.Count).End(xlUp).Offset(1).Resize(LastDate - FirstDate + 1)
.Value = Evaluate("Row(" & CLng(FirstDate) & ":" & CLng(LastDate) & ")")
.NumberFormat = "dd-mmm-yy"
.Offset(, 1).Value = cbLeaveType.Value
.Offset(, -2).Value = tbPnumber.Value
.Offset(, -3).Value = ssheet.Evaluate(.Offset(, -2).Address & "&" & .Address)
End With
MsgBox "Leave Entered"
Unload Me
End Sub
I have the bellow code which takes the inputted start and end date along with the other inputted fields and and lists them besides each individual date within that range on a table in a different sheet.
The issue is that this will list every single date within the range, However I want it to only list the weekdays and not the weekends (Sat and Sun). Any help would be greatly appreciated.
Private Sub cbInputleave_Click()
Dim FirstDate As Date, LastDate As Date
Dim rBlanks As Range
Dim ssheet As Worksheet
Dim ctl As Control
Set ssheet = ThisWorkbook.Sheets("Mark Leave")
FirstDate = tbstartdate.Value
LastDate = tbenddate.Value
With ssheet.Range("D" & Rows.Count).End(xlUp).Offset(1).Resize(LastDate - FirstDate + 1)
.Value = Evaluate("Row(" & CLng(FirstDate) & ":" & CLng(LastDate) & ")")
.NumberFormat = "dd-mmm-yy"
.Offset(, 1).Value = cbLeaveType.Value
.Offset(, -2).Value = tbPnumber.Value
.Offset(, -3).Value = ssheet.Evaluate(.Offset(, -2).Address & "&" & .Address)
End With
MsgBox "Leave Entered"
Unload Me
End Sub