ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Text Conversion (https://www.excelbanter.com/excel-programming/295396-text-conversion.html)

Michael Rekas[_2_]

Text Conversion
 
Hi there

I am importing data from a SQL database.

The date is in column B and appears to be in format dd-mm-yyyy but
does not have the normal date number associated with a date.

I can generate the day number which can then be formatted in date
foemat in one of the following ways:

a) Press F2 followed by Enter on each cell
b) Enter the value 1 in a cell and use Copy, Paste Special, Multiply
on the range. (Thanks to Ralph Rosenfeld for this tip.)

I cannot record or find macro code to cycle through the rows applying
the 1st option.

I have used the following macro for the 2nd option:

Range("A1").Select
Activecell.Value = 1
Selection.Copy
Range("B2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlMultiply

This works on dates beginning with 0 but any date after the 9th of the
month stays the same.

Can anybody help?

Thanks

Michael

Frank Kabel

Text Conversion
 
Hi Michael
try the following macro (works on the selected cells):

sub convert_it()
dim rng as range
set rng = selection
rng.numberformat = "DD-MM-YYYY"
rng.value=rng.value
end sub


--
Regards
Frank Kabel
Frankfurt, Germany


Michael Rekas wrote:
Hi there

I am importing data from a SQL database.

The date is in column B and appears to be in format dd-mm-yyyy but
does not have the normal date number associated with a date.

I can generate the day number which can then be formatted in date
foemat in one of the following ways:

a) Press F2 followed by Enter on each cell
b) Enter the value 1 in a cell and use Copy, Paste Special, Multiply
on the range. (Thanks to Ralph Rosenfeld for this tip.)

I cannot record or find macro code to cycle through the rows applying
the 1st option.

I have used the following macro for the 2nd option:

Range("A1").Select
Activecell.Value = 1
Selection.Copy
Range("B2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlMultiply

This works on dates beginning with 0 but any date after the 9th of

the
month stays the same.

Can anybody help?

Thanks

Michael



Michael Rekas[_2_]

Text Conversion
 
Thanks Frank

Excellent! Worked Perfectly.

Regards

Michael

On Sat, 17 Apr 2004 15:20:11 +0200, "Frank Kabel"
wrote:

Hi Michael
try the following macro (works on the selected cells):

sub convert_it()
dim rng as range
set rng = selection
rng.numberformat = "DD-MM-YYYY"
rng.value=rng.value
end sub




All times are GMT +1. The time now is 03:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com