Have you declared the variable firstdayofweek
that you are passing as a parameter? Have you assigned him value?
This parameter determines the first day of the week (in some countries the week starts on Sunday instead of Monday).
Make sure that this parameter contains a correct value (see the documentation of the function WeekdayName
to see what the parameters are like). In the documentation it is clear that firstdayofweek is optional, so it is not necessary to pass the third parameter, like this:
ActiveSheet.Name = WeekdayName(Weekday(strDate), True) + " " + strDate
Using it like this, firstdayofweek
= 0 by default. Then take the first day of the week from the system configuration.
If you want to specify the first day of the week, the third parameter must have the numerical value of the desired day of the week (Sunday-> 1, Monday-> 2, etc.). So:
ActiveSheet.Name = WeekdayName(Weekday(strDate), True, 2) + " " + strDate
Of course, you can pass a variable with the numerical value instead of putting it in a fixed gear.
It may always return "Sat" because, if that parameter is null
(that is, variable undeclared or with value null
), some function used internally in WeekdayName
could be returning -1
(a Sometimes the functions do that to warn that something has gone wrong). If that were the case, maybe the function is not capturing that error and going ahead with its internal operations (which, if Sunday == 0, could be interpreted as Saturday).