Long Date Format from other sheet

tourless

Board Regular
Joined
Feb 8, 2007
Messages
144
Office Version
  1. 365
Platform
  1. Windows
Hi Folks,

I have a cell on a second sheet with date formatted as 'general', and I'd like to copy that value to another sheet and transpose it to a long date format. Essentially turning this...
2018-07-21
into this...
Saturday, July 21st, 2018
Here's my starting point.
Code:
wsRequired1.Range("B3").Value = "=DP-Required1!A2"
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
If the cell on the second sheet is A1 and holds a date (not text) then this will format that cell to a long date:
Code:
Sheets("name of 2nd sheet").range("A1").NumberFormat = "dddd, mmmm dd, yyyy"
 
Upvote 0
If the cell on the second sheet is A1 and holds a date (not text) then this will format that cell to a long date:
Code:
Sheets("name of 2nd sheet").range("A1").NumberFormat = "dddd, mmmm dd, yyyy"
You missed the ordinal suffix on the day number.



Hi Folks,

I have a cell on a second sheet with date formatted as 'general', and I'd like to copy that value to another sheet and transpose it to a long date format. Essentially turning this...
2018-07-21
into this...
Saturday, July 21st, 2018
Here's my starting point.
Code:
wsRequired1.Range("B3").Value = "=DP-Required1!A2"
Give this formula a try...

=SUBSTITUTE(TEXT(B3,"dddd, mmmm d\x, yyyy"),"x",MID("thstndrdth",MIN(9,2*RIGHT(DAY(B3))*(MOD(B3-11,100)>2)+1),2))

Note: The value in the cell you put this formula in will be text... there is no way to make it a real date value without using VBA code because of your requirement for the ordinal suffix on the day number.
 
Last edited:
Upvote 0
Thanks guys. Here's what I ended up with...
Code:
wsRequired1.Range("B3") = Format(wsDPRequired1.Range("A2"), "dddd, mmmm dd, yyyy")
 
Upvote 0
Thanks guys. Here's what I ended up with...
Code:
wsRequired1.Range("B3") = Format(wsDPRequired1.Range("A2"), "dddd, mmmm dd, yyyy")
:confused: In your original post, you showed you wanted the ordinal suffix on the day number... the above line of code does not include an ordinal suffix... did you change your requirement without telling us?
 
Upvote 0
Yes, didn't see that, just the request for a long date. When a date is formatted as long from the ribbon it doesn't have an ordinal suffix.

Given what the OP wrote in Message #4 , I am wondering how fixed he was on the need for the ordinal suffix.
 
Upvote 0
Apparently, not at all fixed. :cool:
Heh-heh, yeah, I guess not.:confused:

On the off-chance that the OP would actually like the ordinal suffix attached to the day number, here are two different code lines for him to choose from that will do it for him...
Code:
[table="width: 500"]
[tr]
	[td]wsRequired1.Range("B3").Value = Evaluate(Replace("SUBSTITUTE(TEXT(@,""dddd, mmmm d\x, yyyy""),""x"",MID(""thstndrdth"",MIN(9,2*RIGHT(DAY(@))*(MOD(@-11,100)>2)+1),2))", "@", wsDPRequired1.Range("A2").Address)[/td]
[/tr]
[/table]
Code:
[table="width: 500"]
[tr]
	[td]wsRequired1.Range("B3") = Replace(Format(wsDPRequired1.Range("A2"), "dddd, mmmm dd\x, yyyy"), "x", Mid$("thstndrdthththththth", 1 - 2 * ((Day(wsDPRequired1.Range("A2"))) Mod 10) * (Abs((Day(wsDPRequired1.Range("A2"))) Mod 100 - 12) > 1), 2))[/td]
[/tr]
[/table]
 
Upvote 0
You are correct. In my original post I did indicate the ordinal suffix. My solution obviously did not include that, which was my compromise to move forward trying to complete my mission prior to eod. However, I will be revising my code to include not only on this but on many other reports that I've got generating throughout the week. Thanks for all the info guy... I learn a lot here and i appreciate all the input and feedback.
 
Upvote 0

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

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