How do I paste a macro from one spreadsheet to another.
Posted on 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
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.)