henryallen
New Member
- Joined
- Apr 21, 2022
- Messages
- 1
- Office Version
- 365
- Platform
- 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
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