ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   copy date to text (https://www.excelbanter.com/excel-programming/436145-copy-date-text.html)

ulfb[_2_]

copy date to text
 
Hi
One column contains excel dates, formatted like: 2009-11-09.
What I need is to programmatically create a new column containing text only:
20091109
Any help higly appreciated!



Mike H

copy date to text
 
Hi,

Try this

Sub stance()
Dim MyRange As Range
Dim LastRow As Long
LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:A" & LastRow)
For Each c In MyRange
c.Offset(, 1).Value = Format(c.Value, "yyyymmdd")
Next
End Sub


Mike

"ulfb" wrote:

Hi
One column contains excel dates, formatted like: 2009-11-09.
What I need is to programmatically create a new column containing text only:
20091109
Any help higly appreciated!



Don Guillett

copy date to text
 
Sub stringdate()
For Each c In Range("f8:f12")
c.Offset(, 1) = CStr(Format(c.Value, "yyyymmdd"))
Next c
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Mike H" wrote in message
...
Hi,

Try this

Sub stance()
Dim MyRange As Range
Dim LastRow As Long
LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:A" & LastRow)
For Each c In MyRange
c.Offset(, 1).Value = Format(c.Value, "yyyymmdd")
Next
End Sub


Mike

"ulfb" wrote:

Hi
One column contains excel dates, formatted like: 2009-11-09.
What I need is to programmatically create a new column containing text
only:
20091109
Any help higly appreciated!





All times are GMT +1. The time now is 10:20 PM.

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