toggle button size modified via vba

sassriverrat

Well-known Member
Joined
Oct 4, 2018
Messages
655
I'm 99% you can't make a toggle button using code, so can you change the size and location of one via code?

I have a few on a sheet and they seem to have resized/relocated on their own when switch computers and it's quite annoying so I was just going to have code (if possible) to ensure they don't do that again.

Thanks!
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Have you right clicked on the Toggle Buttons and Clicked on Format Control and looked at the Properties?
There are several options there.
 
Upvote 0
If you really need to try this script:
Modify to your needs:
Code:
Private Sub CommandButton1_Click()
'Modified  6/1/2019  1:52:42 AM  EDT
With ActiveSheet.ToggleButton1
    .Left = ActiveCell.Left
    .Top = ActiveCell.Top
    .Width = 250
    .Height = 50
End With
End Sub
 
Upvote 0
For some reason all of the buttons changed sizes/locations as well....but they were easy for me to go back in and code locations/sizes to make sure that doesn't happen again..and this is happening on sheets that are protected.
 
Upvote 0
When you said that's perfect I was not sure you meant the code I provided or setting the formatting.
So is all working now?
And did you fix the problem with the code or by Changing formatting in properties.

I think this happens when you add or delete cells or rows.


For some reason all of the buttons changed sizes/locations as well....but they were easy for me to go back in and code locations/sizes to make sure that doesn't happen again..and this is happening on sheets that are protected.
 
Upvote 0
by the coding- I appreciate all of the help but the coding was what I was looking for.

I haven't deleted/added any rows, that's what caught me off guard- it just up and changed one day....
 
Upvote 0
Glad I was able to help you.
Come back here to Mr. Excel next time you need additional assistance.
by the coding- I appreciate all of the help but the coding was what I was looking for.

I haven't deleted/added any rows, that's what caught me off guard- it just up and changed one day....
 
Upvote 0
Since there isn't such a thing as ActiveCell.Right
How would I go about setting the right side and bottom parameters of the togglebutton (if I wanted it to match teh cell size, instead of specifying a size)? Thanks
 
Upvote 0

Forum statistics

Threads
1,223,755
Messages
6,174,318
Members
452,555
Latest member
colc007

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