Consulting

Results 1 to 3 of 3

Thread: Auto Sort a Worksheet when selected

  1. #1

    Auto Sort a Worksheet when selected

    Hi folks,

    Wondering if this is possible, where by when I select a worksheet the data is sorted by column b.

    I have used the following function, however this depends on the a change being made to a worksheet. The values on this sheet are determined from lookup values and the data will never manually change on this sheet. So the only option appears to be to sort the data when ever a change occurs on the data entry sheet, or when the sheet in question is selected.

    Private Sub Worksheet_Change(ByVal Target As Range)
    Range("B2").Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    End Sub
    Thanks for your help,

    Ger

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Just use the Worksheet_Activate event.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    lol! thanks xld!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •