Hello,
I need to add a column, which takes a date and changes it into 2-digit month number (January -> 01, April -> 04, December -> 12, etc.)
It needs not only to be shown/visible as such (like via custom date cell format), but cell contents really need to be these two digits only - stored as text, because otherwise 01 will be automatically converted to 1.
I got a working code like that:
It does the trick, but goes cell by cell, which is really slow and annoying.
Anyone maybe has a more simple way to do that, or can make code above influence whole column at once?
I need to add a column, which takes a date and changes it into 2-digit month number (January -> 01, April -> 04, December -> 12, etc.)
It needs not only to be shown/visible as such (like via custom date cell format), but cell contents really need to be these two digits only - stored as text, because otherwise 01 will be automatically converted to 1.
I got a working code like that:
VBA Code:
Sub ChangeDateToText()
Dim DateString As String
Dim c As Range
For Each c In Selection
c.NumberFormat = "@"
DateString = Format(Month(c), "00")
c = DateString
Next c
End Sub
It does the trick, but goes cell by cell, which is really slow and annoying.
Anyone maybe has a more simple way to do that, or can make code above influence whole column at once?