ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel, how do I write a macro to convert the date value to text? (https://www.excelbanter.com/excel-programming/373245-excel-how-do-i-write-macro-convert-date-value-text.html)

airedale girl

Excel, how do I write a macro to convert the date value to text?
 
My worksheet contains several thousand records in which I have 3 columns with
date values. I need to know how to write a macro that would add a tick mark
to the beginning of each date to convert it to a text format.

Tom Ogilvy

Excel, how do I write a macro to convert the date value to text?
 
Sub ConvertDates()
Dim cell as Range
for each cell in selection
cell.value = "'" & cell.Text
cell.Numberformat = "General"
Next
End Sub

select the cells to convert and run the macro.

--
Regards,
Tom Ogilvy


"airedale girl" wrote:

My worksheet contains several thousand records in which I have 3 columns with
date values. I need to know how to write a macro that would add a tick mark
to the beginning of each date to convert it to a text format.



All times are GMT +1. The time now is 01:36 AM.

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