simple macro button

excel smurf

New Member
Joined
Aug 21, 2002
Messages
18
instead of clicking on each tab to go to the next spreadsheet, what would a simple macro command be so that I could assign it to a button?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Hi,

Try this...<pre>Sub go_forward()
Dim i As Integer

With ActiveSheet
If .Next.Visible Then
.Next.Select
Else
For i = ActiveSheet.Index + 1 To ActiveWorkbook.Sheets.Count
If Sheets(i).Visible Then
Sheets(i).Select
Exit For
End If
Next i
End If

End With
End Sub

Sub go_back()
Dim i As Integer, x

With ActiveSheet
If .Previous.Visible Then
.Previous.Select
Else
For i = ActiveSheet.Index - 1 To 1 Step -1
If Sheets(i).Visible Then
Sheets(i).Select
Exit For
End If
Next i
End If
End With

End Sub</pre>

_________________
Bye,
Jay

EDIT: Changed routines to handle hidden sheets.

I assume that you need this because you are hiding the sheet tabs? If so, the key combination of Ctrl-PageUp and Ctrl-PageDown will do the same thing.
This message was edited by Jay Petrulis on 2002-08-22 17:29
 
Upvote 0

Forum statistics

Threads
1,224,898
Messages
6,181,625
Members
453,058
Latest member
rmd0725

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top