markkeith
New Member
- Joined
- Sep 8, 2020
- Messages
- 17
- Office Version
- 365
- Platform
- Windows
Is it possible to simplify the Select Case method
with WeekdayName function?
I'm getting the same result even I choose different date.
VBA Code:
Select Case Weekday(Range("startDate"), vbMonday)
Case 1
Range("week").ClearContents
Range("mon").Formula2 = "=IF(ISBLANK(startDate),"""",SEQUENCE(1,days,startDate,1))"
Case 2
Range("week").ClearContents
Range("tue").Formula2 = "=IF(ISBLANK(startDate),"""",SEQUENCE(1,days,startDate,1))"
Case 3
Range("week").ClearContents
Range("wed").Formula2 = "=IF(ISBLANK(startDate),"""",SEQUENCE(1,days,startDate,1))"
Case 4
Range("week").ClearContents
Range("thu").Formula2 = "=IF(ISBLANK(startDate),"""",SEQUENCE(1,days,startDate,1))"
Case 5
Range("week").ClearContents
Range("fri").Formula2 = "=IF(ISBLANK(startDate),"""",SEQUENCE(1,days,startDate,1))"
Case 6
Range("week").ClearContents
Range("sat").Formula2 = "=IF(ISBLANK(startDate),"""",SEQUENCE(1,days,startDate,1))"
Case 7
Range("week").ClearContents
Range("sun").Formula2 = "=IF(ISBLANK(startDate),"""",SEQUENCE(1,days,startDate,1))"
End Select
with WeekdayName function?
VBA Code:
Range("week").ClearContents
Range(WeekdayName(Weekday(StartDate, 2), 1, 2)).Formula2 = "=IF(ISBLANK(startDate),"""",SEQUENCE(1,days,startDate,1))"
I'm getting the same result even I choose different date.