Copy Macro Code from 1 Workbook to Another

SimonGeoghegan

Board Regular
Joined
Nov 5, 2013
Messages
68
Hi All,

I recently created a number of files for different departments - it has since been identified that one of the macros within these spreadsheets is slightly wrong and needs amending.

The NEW macro is as follows;

PHP:
Sub AddLinesActionPlan()

Dim LastRow As Long
Range("B7:K26").Copy
Range("B6").End(xlDown).Offset(1, 0).PasteSpecial
LastRow = Range("B" & Rows.Count).End(xlUp).Row
Range(ActiveCell.Offset(0, 1).Address, "J" & LastRow).ClearContents

Range("B7").AutoFill Destination:=Range("B7:B" & LastRow), Type:=xlFillSeries
Range("A1").Select
MsgBox ("20 additional lines now added.")
End Sub

I want to add the follow line into the existing macro within each workbook;

RangeActiveCell.Offset(0,1).Address,"J" & LastRow).ClearContents


Does anyone know if there is a way of doing this via a macro? The workbooks are all in various different folders/subfolders but if I can add a button to my Excel ribbon that runs code to add the above, that would be great.

I've had a look on the search but most fixes seem to look at importing the module and wasn't sure what impact this may have for me.

Any help greatly appreciated!

Regards,
Simon
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Check out CPearson's web page, or search the net for similar topics, on macro editing other macros. Also, pay attention to the caution on that page for this kind of macros may be regarded as virus by anti-virus programs and deleted without warning.

http://www.cpearson.com/Excel/vbe.aspx
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,936
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top