Macro Buttons

SaraWitch

Active Member
Joined
Sep 29, 2015
Messages
321
Office Version
  1. 365
Platform
  1. Windows
Hello everyone,

I have a couple of macro buttons that go to a specific cell further down the worksheet when clicked. However, if rows are added and deleted, the range doesn't change with the updates and I want to be able to select the original range regardless of row changes. Hope that makes sense! I'm using the following code in VBA:

Sub RoundedRectangle1_Click()​
ActiveSheet.Range("B10").Select​
End Sub​

I'm sure there's a simple way of doing it, but I just can't figure it out! I've tried absolutes, but, of course, they don't work.

Any help would be appreciated...:)
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hello there. In Name Manager define a name for your cell (I used a silly one - BeeTen)
Then this code works:
VBA Code:
Sub RoundedRectangle1_Click()
ActiveSheet.Range("BeeTen").Select


End Sub
 
Upvote 0
Solution
You could use named ranges for your cells.
I named "B10" on a sheet "test" then added rows & columns, but the named cell was still activated with each button press:
VBA Code:
Private Sub CommandButton1_Click()
Me.Range("test").Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,388
Members
448,957
Latest member
Hat4Life

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