Back

  • Thread starter Thread starter tommobot
  • Start date Start date
T

tommobot

is it my imagination or is there a forumla that you can use to go BACK
to the previous sheet that you were on....or am i just imagining it?
somthing like =()back and if it actually does work how do i actually
put it into the workbook?:confused:
 
No such formula that I know of, but it is to create one

It's fairly simple.

Put this code in a normal code module

Public iCurrSheet As Long
Public iPrevSheet As Long

Sub GoBack()
If iCurrSheet <> iPrevSheet Then
Worksheets(iPrevSheet).Activate
End If
End Sub


and this in ThisWorkbook code module


Private Sub Workbook_Open()
iCurrSheet = 1
Worksheets(1).Activate
End Sub

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
iPrevSheet = iCurrSheet
iCurrSheet = ActiveSheet.Index
End Sub

and link your button to the GoBack procedure.


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top