Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro - insert slashes into a cell
I'm having trouble recording a macro that will insert slashes into a cell
that already has data in it. For example, a cell contains the following data "20080723" and I want to create a macro, using "relative references" that will insert slashes as follows "2008/07/23." In other words, I want the macro to create the slashes in that location in the cell regardless of what is in the cell. For example, if the cell contains 20061103, I want the end result to be 2006/11/03. However, when I run the macro, I still get 2008/07/03, regardless of what is in the cell. Can anyone help me? |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro - insert slashes into a cell
Sub MakeDate()
Dim xYear, xMonth, xDay As Double With ActiveCell xYear = Left(.Value, 4) xMonth = Mid(.Value, 5, 2) xDay = Right(.Value, 2) 'Combine and spit out new value ..Value = xYear & "/" & xMonth & "/" & xDay ..NumberFormat = "yyyy/mm/dd" End With End Sub -- Best Regards, Luke M *Remember to click "yes" if this post helped you!* "Cookshack" wrote: I'm having trouble recording a macro that will insert slashes into a cell that already has data in it. For example, a cell contains the following data "20080723" and I want to create a macro, using "relative references" that will insert slashes as follows "2008/07/23." In other words, I want the macro to create the slashes in that location in the cell regardless of what is in the cell. For example, if the cell contains 20061103, I want the end result to be 2006/11/03. However, when I run the macro, I still get 2008/07/03, regardless of what is in the cell. Can anyone help me? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
'IF' Macro to insert cell contents to alternate cell if cell not e | Excel Worksheet Functions | |||
Macro to Insert Current Date into cell - Macro to "Save As" | Excel Worksheet Functions | |||
Macro to insert text into empty cell | Excel Worksheet Functions | |||
Copy and insert cell info macro help | Excel Discussion (Misc queries) | |||
Insert text in a cell with a macro | Excel Discussion (Misc queries) |