+ Reply to Thread
Results 1 to 11 of 11

Using the Change Event to sort data

  1. #1
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Using the Change Event to sort data

    Hi.

    I'd like to use this code

    Please Login or Register  to view this content.

    With the Private Sub Worksheet_Change (ByVal Target As Range), as I do?
    Last edited by marreco; 03-05-2012 at 02:08 PM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Using the Change Event to sort data

    What do you mean? Your question is not very clear.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Using the Change Event to sort data

    Sort the data in the range A2: D10, each time you change a value in the worksheet cell.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Using the Change Event to sort data

    I tried the code in your 1st post and it works fine. What is the issue you are facing?

  5. #5
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Using the Change Event to sort data

    I'm a fool, I thought it does not work.
    But it works!

    How do I sort the code after I fill in the lines of each column in the range A2: D10?

    Example.

    I typed in A2, B2, C2, D2. after digitaar D2. oh yes the code classifies A2: D10.

    I typed in A3, B3, C3, D3. after digitaar in D3. oh yes the code classifies A2: D10.

    And so on!


    Thank you!

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Using the Change Event to sort data

    You can specify a condition if D10 is to be your last cell of entry - code like
    Please Login or Register  to view this content.
    and then the sort code.

  7. #7
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Using the Change Event to sort data

    Look.

    Imagine the range A1: D10 empty, and you have to fill it, from time to time.
    In the range A2: D10.

    the first line A2: D10 is A2: D2.

    the second line A2: D10 is A3: D3.

    the third line A2: D10 is A4: D4.

    So if you type in the first row of A2: D10, only then sorts the data range A1: D10.

    Now you 1st and 2nd row with data. After typing in the last cell (D3) of the 2nd line (A3: D3).
    Only then sorts the data range A1: D10.

    Now you 1st, 2nd and 3rd row with data. After typing in the last cell (D4) of the 3rd line (A3: D3).
    Only then sorts the data range A1: D10.

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Using the Change Event to sort data

    Ok, so ideally the D column should be checked if its filled and then only the sort should be done right? Nothin should be triggered if A, B & C are filled and D is left empty?

  9. #9
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Using the Change Event to sort data

    yes, it is just that.
    correct

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Using the Change Event to sort data

    Try this...there could be other ways of doing this, but this is just one way...
    Please Login or Register  to view this content.

  11. #11
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Using the Change Event to sort data

    Very good!
    this is amazing!
    you know a lot of Excel and VBA.

    Thank you.

+ 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