Dear All
I have two sheets; Names and Data.
The Data sheet is entered with inputs, but the Name field comes from using dropdown validation of NameListRng that comes from the Names sheet.
Now as the Names are added in the last row in the Names sheet it needs to be sorted when i move back and forth to/from the data sheet.
I wish to find out if the code below can be improved
Many thks
Rgds
KNZ
The vba is below:
In the Names worksheet code module I have
In the standard module I have
Public gDefSht As String
I have two sheets; Names and Data.
The Data sheet is entered with inputs, but the Name field comes from using dropdown validation of NameListRng that comes from the Names sheet.
Now as the Names are added in the last row in the Names sheet it needs to be sorted when i move back and forth to/from the data sheet.
I wish to find out if the code below can be improved
Many thks
Rgds
KNZ
The vba is below:
In the Names worksheet code module I have
Code:
Private Sub Worksheet_Deactivate()
gDefSht = ThisWorkbook.ActiveSheet.Name
Call SortOnDeActivate
End Sub
In the standard module I have
Public gDefSht As String
Code:
Sub SortOnDeActivate()
'to avoid going into a loop
Application.EnableEvents = False
'back to deactivated sheet
Worksheet("Names").Select
Call SortNames
'the sheet you where on
Worksheets(gDefSht).Select
Application.EnableEvents = True
End Sub
Sub Call SortNames
code goes here...
which will be the Names sheet
End Sub