+ Reply to Thread
Results 1 to 4 of 4

Sorting after using a macro

  1. #1
    Registered User
    Join Date
    08-11-2012
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    2

    Sorting after using a macro

    It has been a while since I have used macros. I am attempting to place a macro in column A on a spreadsheet that allows the user to use "Ctrl L" to automatically generate the next consecutive number. The entire rows are filled with data that needs to be sorted from time to time, to include column A.
    After using the macro to fill the cell in Column A, complete the data entry in the entire row, then attempt to sort, I recieve a #Value, because the numbers are no longer consecutive. Is there a different code I can use to allow for the consecutive numbers, but also allow for sorting with no errors? This is what I have now, and it is basic, no frills.

    Sub Macro5()
    '
    ' Macro5 Macro
    ''
    ActiveCell.FormulaR1C1 = "=R[-1]C+1"

    End Sub


    Thank you! Here is what I am working on::::

    Complaint # Date Call Rvd Name Phone Type
    11558
    11559

  2. #2
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Sorting after using a macro

    Use a worksheet event macro. Right click on sheet name > veiw code > paste code in the worksheet module.

    Or for example, in my example file, write a complaint name in column "B". it will auto generate the next sequential number
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  3. #3
    Forum Contributor
    Join Date
    08-09-2012
    Location
    Anch, Alaska
    MS-Off Ver
    2003, 2010, 2013
    Posts
    131

    Re: Sorting after using a macro

    I agree with your method JapanDave for a None sorted list, their list gets sorted from time to time.
    The one thing with the Change method, if an adjustment where to take place in an existing cell above.
    The Counter will start placing new numbers at will, this could be a pro or con.

    Yours with a twist.
    Please Login or Register  to view this content.
    Or

    This method below also allows for this and fills in the next number in line by cell selection only (Active Cell).

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    08-11-2012
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Sorting after using a macro

    Thank you both!

+ 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