+ Reply to Thread
Results 1 to 9 of 9

Macro to select rows with appropriate dates and move them into a new worksheet

  1. #1
    Registered User
    Join Date
    01-05-2014
    Location
    Wellington, New Zealand
    MS-Off Ver
    Excel 2013
    Posts
    6

    Macro to select rows with appropriate dates and move them into a new worksheet

    I have an actions register that needs updating on a weekly basis. Rather than manually cutting and pasting for mailouts, I'd like to be able to run a macro each week that will select the rows closest to today's date in the master list and move them into a different worksheet for mailing.

    I've recorded macros before, but after several attempts I now think I need to do it with VBA and I'm a complete novice at that. I've tried using and editing some examples from various forums, but none of them do what I want - possibly because I don't know what I'm doing..... I'm planning to do some online courses, but would really appreciate some help now.

    If it helps, the sheet I'm working from is labelled Action Register, the date is in column K, and the sheet I want the rows to go to is labelled Weekly updates - any help really appreciated!

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro to select rows with appropriate dates and move them into a new worksheet

    Please clarify "closest to today's date".

  3. #3
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Macro to select rows with appropriate dates and move them into a new worksheet

    Hello Catteeya

    apart from the answer to stnkynts question could you post an example of the spreadsheet you are working with. That will help us provide some assistance

    jmac1947

  4. #4
    Registered User
    Join Date
    01-05-2014
    Location
    Wellington, New Zealand
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Macro to select rows with appropriate dates and move them into a new worksheet

    Hi there both of you

    "Today" is the day the macro is run - this will usually be a Friday, as updates need to be in by cob Monday.
    I've attached an example of the sheet (I hope) - what I need is a macro that will select the all of the open actions with the earliest date (in the example that would be 17/01/2014) and move them to a separate sheet.

    (For now I plan to date the actions by Fridays (eg 17 jan, 24 Jan, 31 Jan etc) but if that doesn't work I might look at changing to a date range of up to 5 days prior to "today" - but hopefully by then I'll know how to edit the code!!)

    Thanks in advance for your helpactions register example.jpg

  5. #5
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Macro to select rows with appropriate dates and move them into a new worksheet

    Hi catteeya

    Thanks for the picture, I would have preferred an actual spreadsheet (i really hate transcribing test data into spreadsheet and avoid it if I can)

    I will take a closer look at the picture while I am waiting and start to formulate a solution, stand by for more questions to validate any assumptions I am making in the code
    Jmac1947

  6. #6
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Macro to select rows with appropriate dates and move them into a new worksheet

    Catteya,
    1. are you looking to generate an "actions needed on next Friday" list or a list of ALL open actions with a due date no greater than "next Friday"?
    2. if you are going to execute the macro "manually" would it be OK to simply "ask for the end date" via a dialogue box?, that would solve any number of date related "gotchas" in excel
    Jmac

  7. #7
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Macro to select rows with appropriate dates and move them into a new worksheet

    catteeya-1.xlsm

    Catteeya,

    attached spreadsheet contains a macro that I think should either solve your problem or at least get you well on the way. Please read my assumptions in the macro code to understand what the macro is doing
    There is probably only one key issue to be aware of. Col K in the Action Register tab MUST be formatted as a text column for this macro to be reliable (I have so many problems with date formats and date actions in excel that I simply avoid them whenever I can) and should always be in the format of dd/mm/yyyy

    Hope this assists

    Jmac

    If this solution resolves you issue then please mark the thread "Solved" using the thread tools and if you are happy with the solution suggested then please consider clicking on the "*Add Reputation" button in the lower left of this post

  8. #8
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Macro to select rows with appropriate dates and move them into a new worksheet

    Catteeya,

    attached spreadsheet contains macro that I think should either solve your problem or at least get you well on the way.
    There is probably only one key issue to be aware of. Col K in the Action Register tab MUST be formatted as a text column for this macro to be reliable (I have so many problems with date formats and date actions in excel that I simply avoid them whenever I can) and should always be in the format of dd/mm/yyyy

    Hope this assists

    Jmac

    If this solution resolves you issue then please mark the tread "Solved" using the thread tools and if you are happy with the solution suggested then please consider clicking on the "*Add Reputation" button in the lower left of this post

  9. #9
    Registered User
    Join Date
    01-05-2014
    Location
    Wellington, New Zealand
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Macro to select rows with appropriate dates and move them into a new worksheet

    Thanks, worked great, and sorry about the picture, couldn't figure out how to attach the file - you can see why I need help!! Will work on that for next time!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macros To Move Multiple Rows To Another Sheet And Macro To Move Single Rows To DAX Table
    By jcaynes in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-22-2013, 05:08 PM
  2. Macro to move rows with specific content to another worksheet
    By Bobbington in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-24-2012, 11:05 AM
  3. Macro to move specific rows from one worksheet to another
    By LaughingLaurie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-26-2012, 02:33 PM
  4. [SOLVED] How do I select all the even rows in a worksheet and move them.
    By AM-James in forum Excel General
    Replies: 1
    Last Post: 06-08-2006, 11:45 AM
  5. Move select data to another worksheet
    By Annabelle in forum Excel General
    Replies: 3
    Last Post: 07-27-2005, 01:06 PM

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