Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Text To Date Conversion | New Users to Excel | |||
Date to text conversion | Excel Discussion (Misc queries) | |||
Rotated text conversion | Excel Discussion (Misc queries) | |||
Text to time conversion | Excel Discussion (Misc queries) | |||
Value to text words conversion | Excel Worksheet Functions |