BIGTONE559
Active Member
- Joined
- Apr 20, 2011
- Messages
- 336
I need help with a method of identify the sheet that user was on prior to the active sheet.
For example,
If i have 10 sheets and the user opens the workbook on sheet 1. If the user goes to sheet 10 how could i create a variable to identify the sheet that the user was on prior to sheet 10.
I have the following code:
If it had some way of identifying the sheet Prior to the sheet that was selected i could make changes in my code to account for that.
Thanks
For example,
If i have 10 sheets and the user opens the workbook on sheet 1. If the user goes to sheet 10 how could i create a variable to identify the sheet that the user was on prior to sheet 10.
I have the following code:
Code:
Private Sub Workbook_SheetDeactivate(ByVal sh As Object)
Dim aShRange As Range
Dim aSh As Worksheet
Set aSh = ActiveSheet
Set aShRange = sh.Range("C3")
If sh.Name <> "HExport" Then
If aShRange.Value = "" Then 'test if the value in c3 is blank if it's blank it will name it the index
aSh.Name = aSh.Index
Else
On Error Resume Next
'I have serious issues here. i'm trying to index the sheet whenever a sheet name is changed however, i keep having issues with it.
sh.Name = aShRange.Value
Exit Sub
End If
End If
End Sub
If it had some way of identifying the sheet Prior to the sheet that was selected i could make changes in my code to account for that.
Thanks