Sort on collumn H when leaving sheet

  • Thread starter Thread starter hans
  • Start date Start date
H

hans

I would like sheet "klanten" to be sorted on collumn h when i leave this
sheet to go to an other.
Worksheet_Deactivate does not seems to do the trick becaurce i have to go
back to sheet "klanten" sort and go to the next sheet.
I end up with a loop.

Can someone help?

Greetings Hans
 
Try this?

Option Explicit

Private Sub Worksheet_Deactivate()

Sheets("Klanten").Columns(8).Sort Key1:=Range("H1"),
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

End Sub

This worked for me.
Andrew Armstrong
 
Thanks Hans


AndrewArmstrong said:
Try this?

Option Explicit

Private Sub Worksheet_Deactivate()

Sheets("Klanten").Columns(8).Sort Key1:=Range("H1"),
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

End Sub

This worked for me.
Andrew Armstrong
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top