View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Leroy-P Leroy-P is offline
external usenet poster
 
Posts: 2
Default Previous Worksheet

I copied this a few days ago and it works fine, sorry that I cannot offer
thanks to the author. I failed to write down names.

Please I need everyones help. Thanks

Questions;
1. This code works 90% of the time, but then it locks, I can manually
restart it by using the sheet tags and going to any other sheet, then click
on the command button to revert back to the previous sheet and then that
button starts working again. WHY ?? Whats the fix ???????

2. How can this code be change to stack up to 5 previous worksheets in
memory, rather than flipping back and forth between the two same sheets ??

Previous Worksheet code;
----Placed in Thisworkbook----

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If Not rCurrent Is Nothing Then Set rPrevious = rCurrent
Set rCurrent = ActiveCell
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Excel.Range)
If Not rCurrent Is Nothing Then Set rPrevious = rCurrent
Set rCurrent = Target
End Sub

----Placed in Module1---

Public rPrevious As Range
Public rCurrent As Range

Public Sub GoToPrevious()
If Not rPrevious Is Nothing Then Application.GoTo rPrevious
End Sub