View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Change Numbers to Dates

Assume you want the formula in D2 to the last filled value in column A

Sub change_dates()
dim rng as Range
set rng = range(cells(2,1),cells(2,1).End(xldown))
rng.offset(3,0).Formula = _
"=DATE(VALUE(""20"" & MID(A2,2,2)), " & _
"VALUE(MID(A2,4,2)), VALUE(RIGHT(A2,2)))"
End Sub

the formula is specific to converting a formula in cell A2 - when filled
down, it adjusts to refer to subsequent rows. But if you want to start in a
different row, you would need to change the formula.

--
Regards,
Tom Ogilvy


Donnie Stone wrote in message
...
Gord,

I appreciate your recommendation. I'm new to VBA, will you provide an
example to the range you are referring to?

Regards,
Donnie

<Gord Dibben wrote in message
...
Donnie

Manually enter this in an adjacent column and copy down by

double-clicking
on
the right-hand bottom corner of the cell.

=DATE(VALUE("20" & MID(A2,2,2)), VALUE(MID(A2,4,2)), VALUE(RIGHT(A2,2)))

Note: I interpreted your needs differently than Bob did so you will get
different results. You be the judge.

If need a macro......

Sub change_dates()
Selection.Formula = _
"=DATE(VALUE(""20"" & MID(A2,2,2)), VALUE(MID(A2,4,2)),
VALUE(RIGHT(A2,2)))"
End Sub

Watch for wordwrap.

Select an appropriate range in an adjacent column and run the macro to
replicate the formula down.

Gord Dibben XL2002

On Sun, 2 Nov 2003 17:49:19 -0500, "Donnie Stone"
wrote:

I routinely import files from an AS400 to excel and the dates appear as
follows:

A
1 1031102
2 1031103

A1 equals 11/02/03 & A2 equals 11/03/03.

I'm looking for some help with a macro that would convert the dates
automatically.

Thanks,
Donnie