+ Reply to Thread
Results 1 to 2 of 2

automatically sort a table after changing a cell

  1. #1
    Aaron
    Guest

    automatically sort a table after changing a cell

    I have a table with a colmun that has restricted values to Yes/No. Default
    entry is No. Is it possible to have the table sort itself, so that when this
    cell is changed to Yes, the table sorts itself and puts the rows with Yes in
    that cell at the bottom of the table? Obviously this is very easy to do by
    just sorting it, but as this entry changes a lot and the workbook is shared
    amongst several people, it would be easier if it could be done automatically,
    rather than manually.

    thanks

  2. #2
    Valued Forum Contributor
    Join Date
    12-16-2004
    Location
    Canada, Quebec
    Posts
    363
    Hi

    Did you try something like this


    Private Sub Worksheet_Change(ByVal Target As Range)
    rowcount = Cells(Cells.Rows.Count, "a").End(xlUp).Row
    'you can change the column here change from d to whatever
    Range("a1:" & "d" & rowcount).Select
    'you can change the sort column here change from d to whatever
    'you can change also if there is heater here form Header:=xlNo to Header:=xlYes
    Selection.Sort Key1:=Range("C1"), Order1:=xlAscending, Header:=xlNo, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    'Range("a1").Select

    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1