Moving buttons

cbsox

New Member
Joined
Feb 13, 2023
Messages
2
Office Version
  1. 2021
Platform
  1. Windows
Hi, I have a sheet that has three discrete tables asking information. They are positioned vertically (table 1 above table 2 above table 3). I have a button next to the header of each table which adds a line to the table automatically. It uses the following code:

VBA Code:
Sub Button3_Click()
ActiveSheet.ListObjects("priority1").ListRows.Add AlwaysInsert:=True
End Sub

"priority1" is the first table, "priority2" the second, "priority3" the third.

Each button is set to move and size with cells. This works if I manually insert a new row. However, if I click on the first button to add a row to the section 1 table, the section 2 and 3 tables move down but the buttons do not. How would I go about making the latter two buttons move down as well? Could they be positioned relative to the top right of their respective tables?

Thank you in advance.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Append the following to each Button's Click event This places the Button at the top of and to the right of its table

VBA Code:
With ActiveSheet.Shapes
    .Range(Array("Button 3")).Left = Range("Priority1").Left + Range("Priority1").Width
    .Range(Array("Button 3")).Top = Range("Priority1").Top
End With
 
Upvote 1
Thanks! How would I go about making it align with the table header instead of the top row of the table itself?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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