Problems Inserting Rows

henryallen

New Member
Joined
Apr 21, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi

I am creating a spreadsheet where people will fill in details for certain things, my idea is to have them add rows as they go to each of the tables within the worksheet. However, when they add rows to the first table, this now means that the insert point I chose for the following tables is no longer correct; whenh I click the following ADD NEW ROW buttons they are being inserted too early in the document. The problem seems to be I have an absolute reference when really I need a floating reference for each of the following buttons as the insert point can change. Is anyone able to help please? The code I am using is:

Private Sub CommandButton1_Click()

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

Sheets("Sheet1").Range("B24:F24").Select
Selection.Borders.Weight = xlThin

End Sub

Private Sub CommandButton2_Click()

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

Sheets("Sheet1").Range("B31:D31").Select
Selection.Borders.Weight = xlThin

End Sub

Private Sub CommandButton3_Click()

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

Sheets("Sheet1").Range("B38:D38").Select
Selection.Borders.Weight = xlThin

End Sub

Private Sub CommandButton4_Click()

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

Sheets("Sheet1").Range("B47:F47").Select
Selection.Borders.Weight = xlThin

End Sub

Private Sub CommandButton5_Click()

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

Sheets("Sheet1").Range("B54:D54").Select
Selection.Borders.Weight = xlThin

End Sub

Private Sub CommandButton6_Click()

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

Sheets("Sheet1").Range("B62:F62").Select
Selection.Borders.Weight = xlThin

End Sub

For each of my ADD NEW ROW buttons.

Best regards, Henry
 

Attachments

  • Untitled.png
    Untitled.png
    97.6 KB · Views: 7

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
In your post you use the Term "Table"
A Table is a Range on a sheet.
But your script does not refer to a "Table"
I'm not talking about a sheet.
A "Table" is a defined Range on a Sheet.
See you said this:
as they go to each of the tables within the worksheet
 
Upvote 0

Forum statistics

Threads
1,215,543
Messages
6,125,423
Members
449,223
Latest member
Narrian

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