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

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
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,224,747
Messages
6,180,714
Members
452,995
Latest member
isldboy

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