ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   get the day of week from a date (https://www.excelbanter.com/excel-programming/419355-get-day-week-date.html)

MJKelly

get the day of week from a date
 

Hi,

I am using a variable to hold the day of the week for a given day

Dim DayOfWeek As Date
DayOfWeek = ThisWorkbook.Sheets("Menu").Range("D2").Value

If the value of this cell is a date, how can I have the variable hold
the name of the day of the week? I want to use this to add the day
name to a filename ie Monday Report.xls.

Any ideas?

Kind regards,
Matt

Bob Phillips[_3_]

get the day of week from a date
 
DayOfWeek = Format(ThisWorkbook.Sheets("Menu").Range("D2").Val ue,"dddd")


--
__________________________________
HTH

Bob

"MJKelly" wrote in message
...

Hi,

I am using a variable to hold the day of the week for a given day

Dim DayOfWeek As Date
DayOfWeek = ThisWorkbook.Sheets("Menu").Range("D2").Value

If the value of this cell is a date, how can I have the variable hold
the name of the day of the week? I want to use this to add the day
name to a filename ie Monday Report.xls.

Any ideas?

Kind regards,
Matt




Mike H

get the day of week from a date
 
Hi,

Try this

Dim DayOfWeek As String
DayOfWeek =
WeekdayName(Weekday(ThisWorkbook.Sheets("Menu").Ra nge("D2").Value))

Mike

"MJKelly" wrote:


Hi,

I am using a variable to hold the day of the week for a given day

Dim DayOfWeek As Date
DayOfWeek = ThisWorkbook.Sheets("Menu").Range("D2").Value

If the value of this cell is a date, how can I have the variable hold
the name of the day of the week? I want to use this to add the day
name to a filename ie Monday Report.xls.

Any ideas?

Kind regards,
Matt


Mike H

get the day of week from a date
 
I forgot the other arguments

DayOfWeek =
WeekdayName(Weekday(ThisWorkbook.Sheets("Menu").Ra nge("D2").Value), 0, 1)

Mike

"Mike H" wrote:

Hi,

Try this

Dim DayOfWeek As String
DayOfWeek =
WeekdayName(Weekday(ThisWorkbook.Sheets("Menu").Ra nge("D2").Value))

Mike

"MJKelly" wrote:


Hi,

I am using a variable to hold the day of the week for a given day

Dim DayOfWeek As Date
DayOfWeek = ThisWorkbook.Sheets("Menu").Range("D2").Value

If the value of this cell is a date, how can I have the variable hold
the name of the day of the week? I want to use this to add the day
name to a filename ie Monday Report.xls.

Any ideas?

Kind regards,
Matt



All times are GMT +1. The time now is 02:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com