Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Weekday() result differs from one computer to another ???

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Weekday() result differs from one computer to another ???

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default Weekday() result differs from one computer to another ???

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Weekday() result differs from one computer to another ???

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Weekday() result differs from one computer to another ???

thankyou all. appreciate your help as always...

bobm


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
print differs from spreadsheet BillJ Excel Discussion (Misc queries) 0 April 23rd 09 07:38 PM
Chart Axis Differs Between Excel 03 & 07 pdberger Charts and Charting in Excel 1 October 14th 08 05:48 AM
Formula Bar F9 Result differs from cell result??? Aaron Excel Worksheet Functions 3 May 15th 08 06:32 PM
WEEKDAY() function: display TEXT not numeric weekday tom Excel Discussion (Misc queries) 3 November 21st 06 04:32 PM
Aspect ratio of image differs in print Monika Bjurman Excel Discussion (Misc queries) 1 April 29th 05 12:16 AM


All times are GMT +1. The time now is 11:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"