+ Reply to Thread
Results 1 to 7 of 7

copy data from start to end range

  1. #1
    Forum Contributor
    Join Date
    08-07-2008
    Location
    United States
    MS-Off Ver
    Microsoft Office 2003
    Posts
    362

    copy data from start to end range

    hi,

    can anyone help me how to create a macro which will copy range of data based on a criteria? I have a worksheet which contains dates on column C rows C30:C64, dates would start from march 29 to may 2. how can I copy the range of data from April 1 to April 30? the criteria which will be copied will always be the start of the of the month up to the end of the month...meaning if the dates placed is like April 26 to June 6, it would automatically extract the range for May 1 to May 31 and place this on another sheet.

    regards,

    stoey
    Attached Files Attached Files
    Last edited by stoey; 05-03-2009 at 01:28 AM.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: copy data from start to end range

    here's a non vba approach see sheet 2
    Attached Files Attached Files
    Last edited by martindwilson; 05-02-2009 at 08:06 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Contributor
    Join Date
    08-07-2008
    Location
    United States
    MS-Off Ver
    Microsoft Office 2003
    Posts
    362

    Re: copy data from start to end range

    hi martin,

    i appreciate your response...i checked the attachement you sent and under sheet2, column A rows 2-31 returns #NAME? error any ideas?

    regards,

    stoey

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: copy data from start to end range

    it uses EOMONTH function, you need to activate the analysis toolpak
    tools/addins
    check the analysis toolpak box.
    (note the actual formulas go down to row 31 to allow for all months and are just not showing anything as in this example april only has 30 days)
    Last edited by martindwilson; 05-02-2009 at 06:25 PM.

  5. #5
    Forum Contributor
    Join Date
    08-07-2008
    Location
    United States
    MS-Off Ver
    Microsoft Office 2003
    Posts
    362

    Re: copy data from start to end range

    wow! that works...im not familiar with the uses of add ins...this is another learning...thanks martin... is there any possibility of using a formula without having to use the add ins?


    thanks,

    stoey

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: copy data from start to end range

    that addin is a standard part of excel dont know why its not activated/included as default
    BUT you could replace from a2 dragged down with
    in sheet2 a2

    =IF(ISERROR(A1+1>DATE(YEAR(A1),1+MONTH(A1),1)-1),"",IF(A1+1>DATE(YEAR(A1),1+MONTH(A1),1)-1,"",A1+1))
    that should leave blanks if month only has 28/29/30 days and doesnt require eomonth function
    also i had a rethink
    since you will only have one total month and a bit each side , we can use the median(or average) of those dates to determine which month we require to extract, that cuts the formula in sheet2!a1 to something slimmer
    Attached Files Attached Files
    Last edited by martindwilson; 05-02-2009 at 09:29 PM.

  7. #7
    Forum Contributor
    Join Date
    08-07-2008
    Location
    United States
    MS-Off Ver
    Microsoft Office 2003
    Posts
    362

    Re: copy data from start to end range

    hi there martin,

    thank you so much for the help...the sample workbook you gave me is just perfect for what I need...thanks a lot! you rock!


    regards,

    stoey

+ 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