get week day of a date

A

ashishprem

Hi All,
I want some help regarding date function in macro. I want to know th
week day number of the date. For eg on 30/12/2005 its Friday. I want th
week day number. For eg Sunday -1 ,Monday -2 .... Friday -6 Saturday
7.
For 30/12/2005, the result will be 6. Is there any function to get th
week day number?

Regards
Ashis
 
G

Gary Keramidas

this should do it, i used a1 for the date and b1 for the result

Sub test()
Range("b1").Value = Weekday(Range("a1"))
End Sub

just for reference, if you wanted monday for the first day of the week, then you
would use this and the value would be 5

Range("b1").Value = Weekday(Range("a1"), vbMonday)
 
N

Nigel

Excel worksheet formula WEEKDAY yields the value you require e.g.
=WEEKDAY(A1,1)

The same can be used in VBA code e.g.

MyDOW = Weekday(Range("A1"),1)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top