View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
TroyW[_2_] TroyW[_2_] is offline
external usenet poster
 
Posts: 94
Default SpinButton Change Selection

Marlon,

The difficulty you are observing is due to the SpinButton control taking
focus from the worksheet (you'll notice black rectangles appear around the
SpinButton arrows). The key step is forcing focus back onto the worksheet to
make the cursor reappear.

FYI, the CommandButton control has a property named "TakeFocusOnClick" which
can be set to False to deal with this type of problem. Unfortunately, the
SpinButton control doesn't have this property, so you have to kludge it with
the ActiveCell.Activate command in the GotFocus event of the SpinButton.

Troy


Private Sub SpinButton1_GotFocus()
'Remove the focus from the SpinButton.
ActiveCell.Activate
End Sub

Private Sub SpinButton1_SpinDown()
If ActiveCell.Row < ActiveSheet.Rows.Count Then
ActiveCell.Offset(1, 0).Activate
End If
End Sub

Private Sub SpinButton1_SpinUp()
If ActiveCell.Row 1 Then
ActiveCell.Offset(-1, 0).Activate
End If
End Sub


"Marlon" wrote in message
...
Hi Toppers,

the event "GotFocus" makes nearly what I want:

Private Sub SpinButton1_GotFocus()
With SpinButton1
.Min = 1
.Max = 10
Cells(.Value, 1).Select
End With
End Sub

But if I press the Down-Button the Cursors goes upwards
and if I press the Up-Button the Cursor goes down.
Strange. - Any idea why?

Best regards,
Marlon