Date to Text reversed.

Edgarvelez

Board Regular
Joined
Jun 6, 2019
Messages
197
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

Need a code

The date format is day month Year and the range is dynamic in column A.

Example 6-Nov result would be 20231106 in Column A

Thanks in advance
 

Attachments

  • Date to text.JPG
    Date to text.JPG
    42.7 KB · Views: 7

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Are your entries in column A valid date entries, or text entries?
If date entries, you can use this in column B (cell B2):
Excel Formula:
=TEXT(A2,"yyyymmdd")
 
Upvote 0
Hi All,

Need a code

The date format is day month Year and the range is dynamic in column A.

Example 6-Nov result would be 20231106 in Column A

Thanks in advance
formula works. but is there a code that can do this?
 
Upvote 0
Could you just manually custom format column A as "yyyymmdd"?

Or if it must be code ..
VBA Code:
Sub FormatA()
  Columns("A:A").NumberFormat = "yyyymmdd"
End Sub

Or if the result must be text
VBA Code:
Sub FormatA_v2()
  With Range("A2", Range("A" & Rows.Count).End(xlUp))
    .NumberFormat = "@"
    .Value = Evaluate("text(" & .Address & ",""yyyymmdd"")")
  End With
End Sub
 
Upvote 1
Solution
Are your entries in column A valid date entries, or text entries?
If date entries, you can use this in column B (cell B2):
Excel Formula:
=TEXT(A2,"yyyymmdd")
Thank you. This formula works.
 
Upvote 0
Could you just manually custom format column A as "yyyymmdd"?

Or if it must be code ..
VBA Code:
Sub FormatA()
  Columns("A:A").NumberFormat = "yyyymmdd"
End Sub

Or if the result must be text
VBA Code:
Sub FormatA_v2()
  With Range("A2", Range("A" & Rows.Count).End(xlUp))
    .NumberFormat = "@"
    .Value = Evaluate("text(" & .Address & ",""yyyymmdd"")")
  End With
End Sub

Hi Peter I am having a troubles and I should have given a better explanation from the start, I have 3 sheets Dashboard, Split Shipment Import & Ports and Quality Data.
Ports and Quality Data I use it for my data validations lists which is not part of my problem.

As you can see we are using date month year, so I have to copy from this format and paste to the Split Shipment Sheet.
1701536627917.png



On the split Shipment Import sheet the result has to be as shown below in general format, the reason for the general format is because
because later on with a piece of code that I have I will export the sheet to a .CVS format is because our system will only take .CVS file with the data in General format.

1701536764821.png
 
Upvote 0

Forum statistics

Threads
1,215,106
Messages
6,123,124
Members
449,097
Latest member
mlckr

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