PDA

View Full Version : [SOLVED:] Change date Format



Foncesa
05-21-2017, 10:15 PM
Hi,

I import file wherein the column A date is stored 22/05/2017 want Column A date to be format like 22-05-2017 with macro.

Thanks.

mana
05-22-2017, 02:36 AM
you can use macro recorder.

mdmackillop
05-22-2017, 02:38 AM
Sub DateFormat()
Columns(1).NumberFormat = "dd-mm-yyyy"
End Sub

Foncesa
05-22-2017, 05:45 AM
Hi,

Thanks mdmackillop (http://www.vbaexpress.com/forum/member.php?87-mdmackillop) for the reply, but its not working in my case, i have attached the sample file please have a look.

Thanks.

mdmackillop
05-22-2017, 05:57 AM
Try

Sub DateFormat()
Columns(1).NumberFormat = "dd-mm-yyyy"
Columns(1).Value = Columns(1).Value
End Sub