Edgarvelez
Board Regular
- Joined
- Jun 6, 2019
- Messages
- 197
- Office Version
- 2016
- Platform
- Windows
=text($A2,"yyyymmdd")
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")
formula works. but is there a code that can do this?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
Sub FormatA()
Columns("A:A").NumberFormat = "yyyymmdd"
End Sub
Sub FormatA_v2()
With Range("A2", Range("A" & Rows.Count).End(xlUp))
.NumberFormat = "@"
.Value = Evaluate("text(" & .Address & ",""yyyymmdd"")")
End With
End Sub
Thank you. This formula works.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 worked.Excel Formula:=text($A2,"yyyymmdd")
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