Vba excel problem
Closed
Pm
-
Jul 27, 2010 at 05:20 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Jul 30, 2010 at 09:06 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Jul 30, 2010 at 09:06 AM
Related:
- Vba excel problem
- Number to words in excel formula without vba - Guide
- Vba case like - Guide
- How to open vba in excel mac - Guide
- Excel marksheet - Guide
- Excel free download - Download - Spreadsheets
1 response
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Jul 30, 2010 at 09:06 AM
Jul 30, 2010 at 09:06 AM
You can try this
Dim FirstOfMonth As Date
Dim FourteenOfMonth As Date
FirstOfMonth = CDate(DateSerial(Year(Date), Month(Date) + 1, 1))
FourteenOfMonth = CDate(DateSerial(Year(Date), Month(Date) + 1, 14))
' if day is a saturday, then add 2 days
If (Weekday(FourteenOfMonth, vbMonday) = 6) Then
FourteenOfMonth = DateAdd("d", 2, FourteenOfMonth)
' if day is a sunday, then add 1 day
ElseIf (Weekday(FourteenOfMonth, vbMonday) = 7) Then
FourteenOfMonth = DateAdd("d", 1, FourteenOfMonth)
End If
Cells(3, 1) = FirstOfMonth
Cells(4, 1) = FourteenOfMonth
Of course this does not take into account if here is a holiday
Dim FirstOfMonth As Date
Dim FourteenOfMonth As Date
FirstOfMonth = CDate(DateSerial(Year(Date), Month(Date) + 1, 1))
FourteenOfMonth = CDate(DateSerial(Year(Date), Month(Date) + 1, 14))
' if day is a saturday, then add 2 days
If (Weekday(FourteenOfMonth, vbMonday) = 6) Then
FourteenOfMonth = DateAdd("d", 2, FourteenOfMonth)
' if day is a sunday, then add 1 day
ElseIf (Weekday(FourteenOfMonth, vbMonday) = 7) Then
FourteenOfMonth = DateAdd("d", 1, FourteenOfMonth)
End If
Cells(3, 1) = FirstOfMonth
Cells(4, 1) = FourteenOfMonth
Of course this does not take into account if here is a holiday