Formatting Date as Text and keeping dd-mmm-yyyy format

TXRChav

New Member
Joined
Nov 5, 2015
Messages
10
Hello,

Within a file that is the output of another macro I have a date column. The column has to be in text format as it is intended to be imported into another software that does not like receiving the excel date equivalent value (i.e. 1 represents 1/1/1900). I need to keep the format of dd-mmm-yyyy, but the value in the code is just the equivalent integer.

I have already tried to use

Selection.NumberFormat = "@"

in my vba, but this just converts the day into the equivalent integer in text format. I know the formula

=TEXT(A1,"dd-mmm-yy")

but would prefer not to have to enter the formula in a new column and then cut and copy back into the original column. Does anyone know how to use the vba format code equivalent to the formula to change the value in the cells directly?
 
Last edited:

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Code:
  With range("A1")
    .NumberFormat = "@"
    .Value = Format(.Value, "dd-mm-yyyy")
  End With
 
Upvote 0

Forum statistics

Threads
1,214,647
Messages
6,120,722
Members
448,987
Latest member
marion_davis

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