How to always floating a Command Button on worksheet in Excel?
In some cases, you may need a floating Command Button to keep moving with your worksheet no matter how you scrolling up or down the worksheet. This article will show you method to achieve it.
Recommended Productivity Tools for Excel
Office Tab: Bring powerful tabs to Office (include Excel), just like Chrome, Safari, Firefox and Internet Explorer. Save you half the time, and reduce thousands of mouse clicks for you. 30-day Unlimited Free Trial
Kutools for Excel: Save 71% of your time and solve 82% Excel problems for you. 300+ advanced tools designed for 1500+ work scenario, make Excel much easy and increase productivity immediately.60-day Unlimited Free Trial
Please do as follows to make a Command Button always floating in worksheet.
1. In the worksheet which contains the Command Button you want it to be floating, right click the sheet tab, and then click View Code from the context menu.
2. In the popping up Microsoft Visual Basic for Applications window, copy and paste the below VBA code into the Code window.
VBA code: Make a Command Button always floating in worksheet
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) On Error GoTo 0 With Cells(Windows(1).ScrollRow, Windows(1).ScrollColumn) CommandButton1.Top = .Top + 100 CommandButton1.Left = .Left + 300 End With End Sub
Note: in the abovde code, CommandButton1 is the button name you want to always keep visible. Please change it to your need.
3. Then press the Alt + Q keys to exit the Microsoft Visual Basic for Applications window.
From now on, the Command Button will always float at the top center of the worksheet with the moving of active clicked cell as below screenshot shown.
- How to save and close active workbook without prompt by a Command Button in Excel?
- How to update or insert (current) date and time by a Command Button in Excel?
- How to use a Command Button to change a specified cell value in Excel?
- How to create a Command Button to copy and paste data in Excel?
- How to use Command Button to save active worksheet as PDF file in Excel?
- How to insert a blank new row automatically by Command Button in Excel?
Recommended Productivity Tools
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
To post as a guest, your comment is unpublished.· 7 months agoThanks a lot ... It worked...
To post as a guest, your comment is unpublished.· 1 years agoWorks fine for me. Thx
To post as a guest, your comment is unpublished.· 1 years agoThanks its good with cellselecting
To post as a guest, your comment is unpublished.· 1 years agoNot good QA - check your name on the button. If this is what gets published for the Web community to see, what goes in behind the scenes with the code? :-)
To post as a guest, your comment is unpublished.· 1 years agoI was looking for the Command / Option that when i scroll down the Page the selected Text should be float along with it... How can do that ...
Thank you : Indian Booklet
To post as a guest, your comment is unpublished.· 20 days agoMake a TextBox and then move it when selecting change
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
TextBox1.Text = ActiveCell.Value
With Cells(Windows(1).ScrollRow, Windows(1).ScrollColumn)
TextBox1.Top = .Top + 100
TextBox1.Left = .Left + 300