Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
Don't why I get different a result from one computer to another using the Weekday and Weekday name functions. I am specifying Sunday as weekday 1 not using the default and still get different results. The code I am using is... WeekdayName(Weekday(StartDate, vbSunday), vbSunday) On one computer which is correct I get... 1 Sun 2 Mon 3 Tue... etc On the other I get... 1 Mon 2 Tue 3 Wed... etc The worksheet function works correctly on both but not VBA. Any help appreciated. bobm |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The worksheet function has 2 arguments, the VBA function has 3:
WeekdayName(weekday, abbreviate, firstdayofweek) So where you are using vbSunday it is interpreting it as the 'abbreviate' parameter = 1, True; and because you don't specify the 'firstdayofweek' it takes the default value, which happens to be vbUseSystem - so if the system settings vary on the two computers, the result is different. If this is what is happening, you should be able to fix it by changing the VBA function call to be WeekdayName(Weekday(StartDate, vbSunday), True, vbSunday) -- - K Dales "bobm" wrote: Hello, Don't why I get different a result from one computer to another using the Weekday and Weekday name functions. I am specifying Sunday as weekday 1 not using the default and still get different results. The code I am using is... WeekdayName(Weekday(StartDate, vbSunday), vbSunday) On one computer which is correct I get... 1 Sun 2 Mon 3 Tue... etc On the other I get... 1 Mon 2 Tue 3 Wed... etc The worksheet function works correctly on both but not VBA. Any help appreciated. bobm |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
is the contents of the variable 'StartDate' certainly the same? try something like this: Sub Test() Dim StartDate As Date StartDate = Date MsgBox StartDate MsgBox WeekdayName(Weekday(StartDate, vbSunday), True, vbSunday) End Sub Format(StartDate, "ddd") also would work. http://msdn.microsoft.com/library/en...ateformats.asp http://msdn.microsoft.com/library/en...eekdayName.asp -- HTH, okaizawa bobm wrote: Hello, Don't why I get different a result from one computer to another using the Weekday and Weekday name functions. I am specifying Sunday as weekday 1 not using the default and still get different results. The code I am using is... WeekdayName(Weekday(StartDate, vbSunday), vbSunday) On one computer which is correct I get... 1 Sun 2 Mon 3 Tue... etc On the other I get... 1 Mon 2 Tue 3 Wed... etc The worksheet function works correctly on both but not VBA. Any help appreciated. bobm |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
If you just want the day name, use this simple approach instead: Format(StartDate, "ddd") or Format(StartDate, "dddd") HTH. Best wishes Harald "bobm" skrev i melding ... Hello, Don't why I get different a result from one computer to another using the Weekday and Weekday name functions. I am specifying Sunday as weekday 1 not using the default and still get different results. The code I am using is... WeekdayName(Weekday(StartDate, vbSunday), vbSunday) On one computer which is correct I get... 1 Sun 2 Mon 3 Tue... etc On the other I get... 1 Mon 2 Tue 3 Wed... etc The worksheet function works correctly on both but not VBA. Any help appreciated. bobm |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thankyou all. appreciate your help as always...
bobm |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
print differs from spreadsheet | Excel Discussion (Misc queries) | |||
Chart Axis Differs Between Excel 03 & 07 | Charts and Charting in Excel | |||
Formula Bar F9 Result differs from cell result??? | Excel Worksheet Functions | |||
WEEKDAY() function: display TEXT not numeric weekday | Excel Discussion (Misc queries) | |||
Aspect ratio of image differs in print | Excel Discussion (Misc queries) |