Convert date into string day

Purenergy

New Member
Joined
Jun 2, 2010
Messages
38
Good evening,

I want to convert a date value in a cell into a the day only.

I don't know which expression to use I tried CStr, Value and all types of formulations to do:


HTML:
Dim Date as date
Dim Day as String
 
...
 
Cells(6, 3) = Date
Cells(6, 3).Select
Selection.NumberFormat = "dddd"
Day = Selection
 
If Day = "sunday" Then ...

I hope it is clear enough.

Actually, if my date coulb be analised to see if it is a sunday without having to use the spreadsheet it would be even better but I don't know if it is possible.

If you can help it would be greatly appreciated and if you have questions, I'm here!

Thanks in advance,

P.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
just had a go with your code

Sub dates()



Cells(6, 3) = Date
Cells(6, 3).Select
Selection.NumberFormat = "dddd"

If Selection = "sunday" Then
End If
End Sub

you can not use date as a variable as it returns date
 
Upvote 0
Code:
Sub Day_O_Week()
     
    If Weekday(Date) = vbSunday Then
        MsgBox "Today is Sunday"
    Else
        MsgBox "Today is not Sunday"
    End If
    
End Sub

Or this...
Code:
Sub Day_O_Week2()
     
    If Format(Date, "dddd") = "Sunday" Then
        MsgBox "Today is Sunday"
    Else
        MsgBox "Today is not Sunday"
    End If
    
End Sub
 
Last edited:
Upvote 0
Great!

My problem is solved!

Unfortunately, maybe my example of my macro was not tought of long enough and that is why I used "Date" as a variable.

All my macros are in french and I have to convert them in English when I ask for help on that forum. Please accept my apologies.

But the "Weekday" command with the "vbSunday" gave me exactly what I needed and now it works.

I am always amazed on how fast people help me on this forum( it's the only forum I come to) and it's helped me many times.

Thanks to both of you for your time and consideration.

P.
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,634
Members
452,934
Latest member
Jdsonne31

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top