Worksheet sorting code/technique advise
On Tuesday, August 6, 2013 12:10:12 AM UTC-7, Claus Busch wrote:
Hi Howard,
Am Mon, 5 Aug 2013 16:30:47 -0700 (PDT) schrieb Howard:
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
with SheetDeactivate you will get a error message. Try another event.
What do you know about the sheet? Do you know the column that will be
sorted? Then you could try:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim MyCol As Integer
Select Case Sh.Name
Case "Sheet1"
MyCol = 1
Case "Sheet2"
MyCol = 2
Case "Sheet3"
MyCol = 4
End Select
Regards
Claus B.
Hi Claus,
No I don't know the specific columns nor the sheet names. I was hoping to write some plain jane select case macro where the OP would only have to change the column ranges and sheet names to suit his workbook.
So with the snippet you posted if in Case "Sheet1" there were column 1, $, 7, 8, 12 that needed sorted what would MyCol = look like?
The reason I mentioned sheet deactivate is because the OP wanted to sort upon leaving the sheet. He may need to change his thinking in that regard.
I'm not sure what would be best to evoke the sorts. I'm open to suggestions.
Howard
|