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

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
full code copy from
1701600093084.png

and paste result like this, Note the format that I have in column C is general and I have to keep that format.
1701600360495.png
 
Upvote 0
:unsure: How does 4-Dec in 'Dashboard' become 20231206 in the other sheet? Similarly for 5-Dec becoming 20231208?

In your previous post the dates don't seem to match either with 3-Dec becoming 20231202
 
Last edited:
Upvote 0
sorry my typo errors. it's supposed to be as follows:
20231203
20231204
20231205
 
Upvote 0
Try this.

VBA Code:
Sub Test()
  Dim a As Variant
  Dim i As Long
  
  With Sheets("Dashboard")
    a = .Range("B21", .Range("B" & Rows.Count).End(xlUp)).Value
  End With
  For i = 1 To UBound(a)
    a(i, 1) = Format(a(i, 1), "yyyymmdd")
  Next i
  Sheets("Split Shipment Import").Range("C2").Resize(UBound(a)).Value = a
End Sub
 
Upvote 0
Try this.

VBA Code:
Sub Test()
  Dim a As Variant
  Dim i As Long
 
  With Sheets("Dashboard")
    a = .Range("B21", .Range("B" & Rows.Count).End(xlUp)).Value
  End With
  For i = 1 To UBound(a)
    a(i, 1) = Format(a(i, 1), "yyyymmdd")
  Next i
  Sheets("Split Shipment Import").Range("C2").Resize(UBound(a)).Value = a
End Sub

It worked perfect! thank you very much.
 
Upvote 0
You're welcome. Glad we got there in the end. :)
 
Upvote 1

Forum statistics

Threads
1,215,093
Messages
6,123,067
Members
449,090
Latest member
fragment

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