+ Reply to Thread
Results 1 to 19 of 19

Sort rows in a workbook based on Date in Row A

  1. #1
    Forum Contributor
    Join Date
    07-02-2013
    Location
    abbots langley
    MS-Off Ver
    Excel 2010
    Posts
    316

    Sort rows in a workbook based on Date in Row A

    This sounds very simple, however i have searched many forums and tried various codes but without sucess, my data spreads from Columns A to R and starts in row 4.

    Would be grateful if someone could help me with the code to sort the data by column A

    many thanks

  2. #2
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: Sort rows in a workbook based on Date in Row A

    Hi michelle..

    below is just a recorded macro.. check this..

    Please Login or Register  to view this content.
    Regards!
    =DEC2HEX(3563)

    If you like someone's answer, click the star to give them a reputation point for that answer...

  3. #3
    Forum Contributor
    Join Date
    07-02-2013
    Location
    abbots langley
    MS-Off Ver
    Excel 2010
    Posts
    316

    Re: Sort rows in a workbook based on Date in Row A

    Thanks Debraj for your prompt response. Does this mean i need a button as i was hoping for it to apply automatically upon opening.

  4. #4
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: Sort rows in a workbook based on Date in Row A

    OK.. You want this automatically upon opening .. then..

    in ThisWorkbook Section.. in Workbook_Open() use below code..
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    07-02-2013
    Location
    abbots langley
    MS-Off Ver
    Excel 2010
    Posts
    316

    Re: Sort rows in a workbook based on Date in Row A

    Hi Debraj, i am receiving a Runtime error 9 subscript out of range, any ideas?

  6. #6
    Registered User
    Join Date
    07-10-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Sort rows in a workbook based on Date in Row A

    Try this,

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    07-02-2013
    Location
    abbots langley
    MS-Off Ver
    Excel 2010
    Posts
    316

    Re: Sort rows in a workbook based on Date in Row A

    Hi thanks for responding.

    I was googling this as we speak without any luck, I Assume I need to change "Partial Shifts" and "Day off Trades" are these the tab names? I have 12 tabs - January to February. Appologies for asking a silly question but i am new to this. My Worksheet is called Events Spreadsheet.

    Really appreciate your help.

  8. #8
    Registered User
    Join Date
    07-10-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Sort rows in a workbook based on Date in Row A

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    07-02-2013
    Location
    abbots langley
    MS-Off Ver
    Excel 2010
    Posts
    316

    Re: Sort rows in a workbook based on Date in Row A

    Thank you so much, i have my header in Row 3 and it is placing the data above this, what part of the code do i need to ammend? really really appreciate your help.

  10. #10
    Forum Contributor
    Join Date
    07-02-2013
    Location
    abbots langley
    MS-Off Ver
    Excel 2010
    Posts
    316

    Re: Sort rows in a workbook based on Date in Row A

    Would you mind checking my code, i guessed based on what you gave me. It actually works fine, however i get an error message saying excel found unreadable content this appeared after i entered the code, if i click on yes this is from a trusted source its fine and sorts perfectly but obviously i have done something wrong?!

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    07-10-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Sort rows in a workbook based on Date in Row A

    if you want to add worksheet automatically then use this code

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    07-02-2013
    Location
    abbots langley
    MS-Off Ver
    Excel 2010
    Posts
    316

    Re: Sort rows in a workbook based on Date in Row A

    Hi thanks again for replying.

    I am really sorry to ask but where do i insert the code and what part of my code do i need to remove, i really am very new to this and willing to learn.

  13. #13
    Registered User
    Join Date
    07-10-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Sort rows in a workbook based on Date in Row A

    You don't need to declare 12 object for 12 months saperately you just add the above code that I given to you that add worksheet automatically to your workbook.
    That code you have to place within the loop.

    Look at this sample code:

    Please Login or Register  to view this content.
    I hope you understand.

  14. #14
    Forum Contributor
    Join Date
    07-02-2013
    Location
    abbots langley
    MS-Off Ver
    Excel 2010
    Posts
    316

    Re: Sort rows in a workbook based on Date in Row A

    Hi, as i said i am a real newbie i cant read the code but i have been playing around wth it for an hour and a half. I have the following, i have been adapting your code to the sample code, am i on the right tracks??

    Please Login or Register  to view this content.
    I think i need settig straight with what i have and then i will have another go, i am self teaching so do not understand the terminology of the code.

    Thansk for helping me get my head round it. (Sorry reposted with code tags and not HTML!)

  15. #15
    Registered User
    Join Date
    07-10-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Sort rows in a workbook based on Date in Row A

    you done wrong man.

    I attached image with this post.

    check it.

    code.JPG

  16. #16
    Forum Contributor
    Join Date
    07-02-2013
    Location
    abbots langley
    MS-Off Ver
    Excel 2010
    Posts
    316

    Re: Sort rows in a workbook based on Date in Row A

    Thanks for your reply and the code explanation. My code knowledge is very basic and therfore i am unable to interpret the information you are giving me. Im not sure what i need to change/add on your sample. I will have to leave it and manually sort my data on each tab as i really do not understand how to write it from what you have provided.

    Thanks for your patience.

  17. #17
    Registered User
    Join Date
    07-10-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Sort rows in a workbook based on Date in Row A

    I send you the sample code. check this.

    run this code and see the output.
    Attached Files Attached Files
    Last edited by ankitparate; 07-11-2013 at 09:44 AM.

  18. #18
    Forum Contributor
    Join Date
    07-02-2013
    Location
    abbots langley
    MS-Off Ver
    Excel 2010
    Posts
    316

    Re: Sort rows in a workbook based on Date in Row A

    I have done it i fiddled around with what i was doing and it works, admittedly its probably not pretty but it does the job. Thansk so much for your patience and help.

    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    07-10-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Sort rows in a workbook based on Date in Row A

    Anytime.

    If you want more help then ask me

+ 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