Thread: Moving Shape
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Moving Shape

Scrolling the window does not trigger any events (at least none exposed to
Excel vba).

You could move the shape, if necessary, the next time user selects a cell.

' in the sheet module
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim shp As Shape

On Error Resume Next
Set shp = Me.Shapes("Rectangle 1")
On Error GoTo errExit

If shp Is Nothing Then
Exit Sub
End If

With ActiveWindow
If Intersect(.VisibleRange, shp.TopLeftCell) Is Nothing Then
With .VisibleRange(2, 2)
shp.Left = .Left + 3#
shp.Top = .Top + 3#
End With
End If
End With

errExit:

End Sub

Change the name of the shape to suit and the default position relative to
the top left visible cell. Alternatively could position relative to the new
activecell.

Regards,
Peter T



"K" wrote in message
...
Hi all, I got Rectangle shape on my sheet and I want vba with which
shape should move on sheet whenever a user use active window scroll.
In other words when user move active window scroll up and down the
shape should also move with it and shape should always be appear or
visible in visible area of sheet. I tried doing search on this forum
but couldn't find any useful answer for my question. I know there are
lot of vba expert friends out there who know the sultion for my
question so can any friend help me on this. Many thanks in advance.