Locating command button

jonnynacker

New Member
Joined
Sep 11, 2014
Messages
46
Hey guys,
have a workbook which will continually hide and unhide command buttons so each time they must be located back to where they are needed. I am fine with locating them to a cell in the " top left corner" using this script for all the command buttons;

Code:
Sheet4.CommandButton98.Top = Sheet4.Range("D38").Top
Sheet4.CommandButton98.Left = Sheet4.Range("D38").Left

I want them to be located in the top right though, any suggestions?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Code:
    Dim r As Range

    With Sheet4
        Set r = .Range("D38")
        With .CommandButton98
            .Top = r.Top
            .Left = r.Left + r.Width - .Width
        End With
    End With
 
Upvote 0
You could use something like this after you determine the correct increment to use:

Sheet4.CommandButton98.IncrementLeft #

where # is the number of points of increment needed to move the button to the right side of the cell (yes, I know its IncrementLeft, but it will move right).

To calibrate you - column width is measured in characters. The default width is 8.43 which is 48 points.
 
Upvote 0

Forum statistics

Threads
1,215,029
Messages
6,122,755
Members
449,094
Latest member
dsharae57

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