Macro buttons to add rows to schedule

Hugoprince

New Member
Joined
Feb 24, 2015
Messages
1
Hi
I'm new to creating macro's!
I've found some code that adds a new row below a specified range and I've got this working.
However the issue I have is that I have created multiple macro buttons for each sub-element of the schedule and when I click "Add Row" and a new row is added to the first sub-element all the below "add Row" macro buttons are then thrown out of synch. I want the code to allow for added rows above, so that the below "Add row" buttons automatically move down.
The code I have used is:

Private Sub CommandButton21_Click()

Sheets("Sheet1").Range("A8").Select
ActiveCell.EntireRow.Insert Shift:=xlDown

Sheets("Sheet1").Range("A8:F8").Select
Selection.Borders.Weight = xlThin

End Sub

Private Sub CommandButton210_Click()
Sheets("Sheet1").Range("A60").Select
ActiveCell.EntireRow.Insert Shift:=xlDown

Sheets("Sheet1").Range("A60:F60").Select
Selection.Borders.Weight = xlThin
End Sub

Private Sub CommandButton211_Click()
Sheets("Sheet1").Range("A65").Select
ActiveCell.EntireRow.Insert Shift:=xlDown

Sheets("Sheet1").Range("A65:F65").Select
Selection.Borders.Weight = xlThin
End Sub

can anyone help?

thanks
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,215,695
Messages
6,126,263
Members
449,307
Latest member
Andile

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