+ Reply to Thread
Results 1 to 8 of 8

VBA Sorting Rows automatically

  1. #1
    Registered User
    Join Date
    11-17-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Question VBA Sorting Rows automatically

    Hi guys,

    I am a VBA noob and have been looking for something that might suit for days.
    Basically I d like excel to automatically sort all used rows in a spreadsheet according to the value in, let's say, column B. It contains names from RSVP address book.
    Values can be numbers (from 1 to i.e. 4), cancelled, declined and no reply.
    I d like to have last three categories of rows be moved below so that i can have first rows with numbers, then all the others.

    I d appreciate your kind help in this

    Cheers

  2. #2
    Forum Contributor
    Join Date
    10-31-2012
    Location
    Maryland, USA
    MS-Off Ver
    Excel 2003/2007
    Posts
    145

    Re: VBA Sorting Rows automatically

    reyearthnexus,

    I have made a spreadsheet that will automatically sort by RSVP when something new is added or changed in column C. I am not sure what the numbers are for. If you have a spreadsheet that you can post I will be more than happy to apply it to yours so it works the way you want it to.


    Simeon
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    11-17-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: VBA Sorting Rows automatically

    Hi Simeon

    it seems to work perfectly indeed! thanks!
    Please find attached a screenshot of the spreadsheet where I am working on.
    Could please really adapt your code to that ?
    thank you so much
    exampl.png

  4. #4
    Forum Contributor
    Join Date
    10-31-2012
    Location
    Maryland, USA
    MS-Off Ver
    Excel 2003/2007
    Posts
    145

    Re: VBA Sorting Rows automatically

    So I have put the code into the new format. Whenever you enter a new person be sure to input the RSVP number in last. That is what triggers the macro. Hope this works for you!


    Simeon
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-17-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: VBA Sorting Rows automatically

    That's great, thank you very much!
    I got just one question: I was looking at the code for the parameter which drives the array affected by the macro. What if i want to make more columns be interested?
    I expected to find something like Range(A1:G10)

    Many tha

  6. #6
    Forum Contributor
    Join Date
    10-31-2012
    Location
    Maryland, USA
    MS-Off Ver
    Excel 2003/2007
    Posts
    145

    Re: VBA Sorting Rows automatically

    Sure!

    In the macro that is under Sheet1 it looks like this.
    Please Login or Register  to view this content.
    In the second line
    Please Login or Register  to view this content.
    That is where you would change the Range from just Column B into whatever range you want.
    Then any changes in that range will trigger the macro.
    Don't forget to click the star in this post!

  7. #7
    Registered User
    Join Date
    11-17-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: VBA Sorting Rows automatically

    Thank you very much Simeon, it is great!!

    I was wondering one last (promise) thing: is it possible to eventually add a condition in the target range, like (if entry <>""), so that it would be possible to add eventually blank rows that are effected by the macro only when I put something in the relative cell B. Does it make sense?
    I dd like to offer you a massive beer for that if we werent that far

  8. #8
    Forum Contributor
    Join Date
    10-31-2012
    Location
    Maryland, USA
    MS-Off Ver
    Excel 2003/2007
    Posts
    145

    Re: VBA Sorting Rows automatically

    Yeah that makes sense.
    You can add as many rows to the data as you like because the macro runs all the way down to B1000. If you need more lines for data you can always just go in and change the macro from B1000 to B:B that would give you all of the rows in excel. Also It currently works whenever something is changed or added on column B. I know the code looks weird but thats what it is saying in the first Sub. Thanks for the virtual beer offer. I will have one tonight and cheers to you reyearthnexus!


    Simeon

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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