Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
'IF' Macro to insert cell contents to alternate cell if cell not e Gryndar Excel Worksheet Functions 6 December 20th 08 05:02 PM
Macro to Insert Current Date into cell - Macro to "Save As" Guy[_2_] Excel Worksheet Functions 4 December 12th 08 08:20 PM
Macro to insert text into empty cell Teresse Excel Worksheet Functions 8 October 29th 07 03:32 AM
Copy and insert cell info macro help JackR Excel Discussion (Misc queries) 2 March 21st 06 03:22 PM
Insert text in a cell with a macro kayabob Excel Discussion (Misc queries) 5 June 22nd 05 05:43 PM


All times are GMT +1. The time now is 08:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"