|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| 10/24/2009 at 11:10AM PDT, ID: 24840760 | Points: 250 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: |
' For the Code to work, create a sheet called 'Hist' in the workbook
''Code that goes into ThisWorkbook area
Public Sh As String, sht As Worksheet, asht As Workbook, r As Integer
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Set sht = ThisWorkbook.Sheets("hist")
sht.Cells.ClearContents
End Sub
Private Sub Workbook_Open()
Set sht = ThisWorkbook.Sheets("hist")
Set asht = ActiveWorkbook
r = sht.Cells(1, 2)
If IsNull(r) Or r = 0 Then r = 1
sht.Cells(r, 1) = asht.ActiveSheet.Name
sht.Cells(r, 2) = r + 1
End Sub
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Set sht = ThisWorkbook.Sheets("hist")
Set asht = ActiveWorkbook
r = sht.Cells(1, 2)
sht.Cells(r, 1) = asht.ActiveSheet.Name
sht.Cells(1, 2) = r + 1
End Sub
''Code that goes into Module1
Public Sh As String, sht As Worksheet, asht As Workbook, r As Integer
Sub go_back()
Set sht = ThisWorkbook.Sheets("hist")
Set asht = ActiveWorkbook
r = sht.Cells(1, 2)
r = r - 1
If r <= 0 Then
MsgBox "Reached last item in the history"
Else
s = sht.Cells(r, 1)
asht.Sheets(s).Select
sht.Cells(1, 2) = r
End If
End Sub
|
Advertisement