Results 1 to 8 of 8

Thread: Solved: commandbutton that "follows" cursor

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    VBAX Expert
    Joined
    Sep 2010
    Posts
    604
    Location
    This won't work for scrolling,
    but if by "follow the cursor" you mean follow a selection change, then perhaps something like this:
    [vba]Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Dim Shp As Object

    Set Shp = ActiveSheet.CommandButton1

    With Shp
    .Left = ActiveCell.Left
    .Top = ActiveWindow.Top
    .Width = Range("A1").Width ' or a desired fixed width
    .Height = Range("A1").Height ' or a desired fixed height
    End With

    Shp.Object.TakeFocusOnClick = False'Optional. keeps focus on the selected cell instead of the button

    End Sub
    [/vba]
    Last edited by frank_m; 09-09-2011 at 12:31 PM. Reason: edited the code comments

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •