Automatic top of sheet?

  • Thread starter Thread starter bowe
  • Start date Start date
B

bowe

I am using buttons for navigating between sheets but I also want th
destination sheet to be automatically scrolled to top of page when i
is displayed. The code i am using is simply:

Private Sub CommandButton2_Click()
On Error Resume Next
ActiveSheet.Previous.Select
If Err Then ActiveSheet.Next.Select
End Sub

I tried to add a selection of cell A1:

Private Sub CommandButton2_Click()
On Error Resume Next
ActiveSheet.Previous.Select
*Range("A1").Select*
If Err Then ActiveSheet.Next.Select
End Sub

...but of course the destination sheet was shown briefly and then cel
A1 in the current sheet was selected. Is there any work around this?

Grateful for any help!
/Bow
 
One way:

Private Sub CommandButton2_Click()
With ActiveSheet
If .Index = 1 Then
.Next.Select
Else
.Previous.Select
End If
End With
ActiveSheet.Range("A1").Select
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top