nope, different idea.......
(i randomized it, that's what's in the cells in the spreadsheet. you
could easily take that out).... watch the word wrapping.
********************************
in the worksheet:
cell K701 = =RAND()*5
cell K702 = =ROUND(K701,0)
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
'by Orlando Magalhães Filho in .programming
'revised 6/28/07 - added the commandbutton movement
'as below - original code did not dim variables
Dim x_offset As Long
Dim y_offset As Long
Dim xpos As Long
Dim ypos As Long
'revised 7/16/07
'added a random control controlling this action,
'doing it every time there was a worksheet_change
'was too slow & cumbersome.
'this does it frequently enough to
'update it often.
If Range("k702") = 4 Then
Application.ScreenUpdating = False
x_offset = 305 'was 10 2 makes it top left corner 305 makes it
start @ column J
y_offset = 2 'was 10 2 makes it top left corner
ActiveSheet.Shapes("CommandButton1").Select
With Cells(ActiveWindow.Panes(1).ScrollRow, _
ActiveWindow.Panes(1).ScrollColumn)
' xpos = .Right + x_offset THERE IS NO .RIGHT PROPERTY
xpos = .Left + x_offset
ypos = .Top + y_offset
End With
With Selection
.Left = xpos
.Top = ypos
End With
Target.Select
Application.ScreenUpdating = True
End If
End Sub
*************************
hope it helps!
susan