Link to home
Start Free TrialLog in
Avatar of Carlandrewlewis
CarlandrewlewisFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Excel - Floating Command Button

At the moment i have to keep scrolling to the top right of the spreadsheet to press the command button, is there anyway to set a command button to move with the spread sheet?
Job-sheet-2008.xls
Avatar of StellanRosengren
StellanRosengren
Flag of Sweden image

Hi Carlandrewlewis,

If you put this code in the sheet module for the table with the button it will move the button when you change selection. You can change the constants as you wish.

Regards,
Stellan
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim cmdBtn As Shape
    
    Set cmdBtn = Me.Shapes("BUTTON 110")
    
    cmdBtn.Left = ActiveWindow.VisibleRange.Left + 0.6 * ActiveWindow.VisibleRange.Width
    cmdBtn.Top = ActiveWindow.VisibleRange.Top + 0.6 * ActiveWindow.VisibleRange.Height
    
End Sub

Open in new window

Avatar of Carlandrewlewis

ASKER

That works perfect, is there any way to lock it to specific columns?
ASKER CERTIFIED SOLUTION
Avatar of StellanRosengren
StellanRosengren
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect thanks for your help