Solved

How do I paste a macro from one spreadsheet to another.

Posted on 2016-11-17
2
22 Views
Last Modified: 2016-11-17
We have a spreadsheet (97-2003) that some cells have a custom format of 0000-00-00
When you enter 1234, you get 1234-00-00 instead of 0000-12-34.
This is happening because of the following macro:

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub
    'modify the range A1:A20 to match your input cells
    If Not Intersect(Target, [j8:J46]) Is Nothing Then
        Application.EnableEvents = False
        Target.Value = Replace(Left(Target.Value & Space(8), 8), " ", "0")
        Application.EnableEvents = True
    End If
End Sub

How do I put this macro into a new spreadsheet to achieve the entry results?
 (I realize that the macro affects cells j8 through j46 and I will have to modify the cell range appropriately and use a macro-enabled workbook.)
0
Comment
Question by:Bill Golden
2 Comments
 
LVL 32

Accepted Solution

by:
Rob Henson earned 500 total points
ID: 41891248
That is a Worksheet specific code. So, in the workbook that needs to receive the code, right click on the tab of the worksheet where you need the entries to change and select View Code. This will open the Visual Basic Editor and will show the code for that sheet. Copy and Paste into the "document" module pane on the right hand side.
0
 
LVL 1

Author Closing Comment

by:Bill Golden
ID: 41891420
That fixed it immediately.
Thanks
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

806 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question