Link to home
Start Free TrialLog in
Avatar of ExpressMan1
ExpressMan1Flag for Canada

asked on

Format column and fill with date.

Hello,

I have column D with data in general format which are Invoice Dates. Example:

20130910
20130910
20130910

I am trying to get column C to show the dates as 10/09/2013

Here is the code I am using. I am getting type mismatch error.

Sub Invoice_Date()

Sheets("Sheet1").Select
Columns("C:C").Select
Selection.NumberFormat = "dd/mm/yyyy;@"
   
Selection.Formula "=DATEVALUE(MID(D2,5,2)&" / "&RIGHT(D2,2)&" / "&LEFT(D2,4))"

Selection.AutoFill Destination:=Range("C2").End(xlDown).Select
Range("D2").End(xlDown).Select
Selection.Columns.AutoFit

End Sub
ASKER CERTIFIED SOLUTION
Avatar of FamousMortimer
FamousMortimer
Flag of United States of America 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
Avatar of ExpressMan1

ASKER

Perfect.   Thanks!