Code to Insert 'x' amount of rows

bmkelly

Board Regular
Joined
Mar 26, 2020
Messages
172
Office Version
  1. 365
Platform
  1. Windows
I currently have

Sub FYInsertRows()

Dim Rows As Variant

Rows = InputBox("How many rows?")
If Rows = "" Then Exit Sub
ActiveCell.EntireRow.Resize(Rows).Insert

End Sub

which works but the issue I run into with others in my department is that we open new templates and workbooks so often that it gets hard to keep adding in this code every single new template/workbook we work out of.

Is there a way to have some sort of batch file or some way in excel that I could easily transfer the VBA code over into other workbooks without creating chaos by re-adding the code to every workbook?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
You could create a workbook with the code you want and save it as an excel addin so that everyone can use it regardless of the workbook they have open. You will need to add more code to identify the active workbook and active worksheets but that would be the easiest solution. You could then update with other tools you create and simply have them install the new addin.
 
Upvote 0
Solution
You could create a workbook with the code you want and save it as an excel addin so that everyone can use it regardless of the workbook they have open. You will need to add more code to identify the active workbook and active worksheets but that would be the easiest solution. You could then update with other tools you create and simply have them install the new addin.
Okay! I originally had the code on a template but we ended up having more templates and then when it becomes a new year then more get added/updated so it became harder to keep track of.

So you suggest just putting the code in a blank workbook and saving that out to a sharedrive then adding the macro as an addin on the quick access toolbar correct? If so, my follow up question would be for every workbook that we end up opening would we have to add the addin every single time? (I assume so but just want to check my boxes first before sending anything out to the team)
 
Upvote 0
Add-ins are added to the users instance of excel so that they are independent of the workbook\worksheet being worked on. I don't have too much experience with this but there should be posts that direct you on how to create them
 
Upvote 0

Forum statistics

Threads
1,215,005
Messages
6,122,661
Members
449,091
Latest member
peppernaut

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