Thread: floating button
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Jack Sons Jack Sons is offline
external usenet poster
 
Posts: 144
Default floating button

Hi all,

On my worksheet I have a button of which the name is "historie". When
clicked it starts a certain macro.
The sheet is rather wide, col. A up to col. FH.
The button is now in a fixed position, in cell A1 but I want the button to
float so that when I scroll more than 16 columns to the right the button
will appear in the upper left corner of the then visible part of the
worksheet as soon as I select a cell in the that part of the worksheet.
From one of the helpful persons in this NG many years ago I got the code
below - which I put in the program module of the worksheet - and it worked
well. I want to get that effect again but the button remains fixed to its
original positition.
What is wrong? Thanks in advance for your help.

Jack Sons
The Netherlands



Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.DisplayCommentIndicator = xlCommentIndicatorOnly
If ActiveCell.Column 16 Then

Dim myShape As Shape

Set myShape = Me.Shapes("historie")

With Me.Cells(ActiveWindow.ScrollRow, ActiveWindow.ScrollColumn)
'With Me.Cells(1, ActiveWindow.ScrollColumn)
myShape.Top = 30 '.Top
myShape.Left = .Left
End With
End If
End Sub