Link to home
Start Free TrialLog in
Avatar of Gazza83
Gazza83

asked on

VB Code excel

The following code helps me convert date values into dd-mmm-yyyy, what I'd like to do in addition is then convert the values into text.

So it would stay as dd-mmm-yyyy but the cell value would be text not a date format. I thought one way maybe to text special, but at the moment I have to paste the values into notepad and then pre format the cells so that they enter as text.

Private Sub CommandButton1_Click()
Dim cell As Range
For Each cell In Selection
cell.NumberFormat = "dd-mmm-yyyy"
Next cell

End Sub

Many thanks for your help.
Avatar of Joe Howard
Joe Howard
Flag of United States of America image

Why not use the Text To Columns feature from the data tab?
ASKER CERTIFIED SOLUTION
Avatar of Shums Faruk
Shums Faruk
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Gazza83
Gazza83

ASKER

Many thanks for your help!
Pleased to help!
Not sure why you have chosen the example using a Loop when my code is more efficient because it doesn't use a Loop.

See here