Macro to copy and paste data between date&time code

  • Hi
    I am trying to create a macro that will find a date&time, then copy all the lines of data below that date&time (all info is in the same column e.g. A:A), pasting each line of data in the same row as said data&time but with each line of data being pasted into a different column. i.e.



    Before:-------------------------- After:
    19/07/86 14:08:00-----------19/07/86 14:08:00 | Mr x | received x | received x | received x
    Mr x-------------------------------Mr x
    received x-----------------------received x
    received x-----------------------received x
    received x-----------------------received x



    However i want it on a loop, so that as soon as it finds another date&time in the same column it starts doing the same again. This has to occur for the entire spreadsheet (all data is in the same column). NB: date and time may be just date and may be in a different format, and information below the date&time (or just date) is not always the same i.e.



    Before:---------------------------After:
    19/07/86 14:08:00-----------19/07/86 14:08:00 | Mr x | received x | received x | received x
    Mr x------------------------------- Mr x
    received x-----------------------received x
    received x-----------------------received x
    received x-----------------------received x
    22/07/86 08:23:53-----------22/07/86 08:23:53 | Mr y | reposted y | received y |
    Mr y-------------------------------Mr y
    reposted y----------------------reposted y
    received y----------------------received y
    01-Oct-87-----------------------01-Oct-87 | Mr z | received z | received z | No del z | received z
    Mr z-------------------------------Mr z
    received z-----------------------received z
    received z-----------------------received z
    No del z-------------------------No del z
    received z----------------------received z



    After this i would like to turn the row with the date&time and pasted data to be formatted orange so that i can extract this information into another sheet based on the colour of the row. Once this is done i have a macro to extract all orange rows into another sheet.



    I'm pretty stuck on this one (partly as i cant get the macro to identify all the different date and time formats i am using and i cant figure out why). Any help anyone could give me would be VERY much appreciated.



    Thanks



    Mattdave86

  • Re: Macro to copy and paste data between date&time code


    Hi Matt,


    Welcome to OzGrid. Have you got a sample workbook? Seems simple enough just creating a loop and array....


    C

  • Re: Macro to copy and paste data between date&time code


    Hi Craig
    I am quite new to this kind of work, and this one just stumped me i am afraid. I have attached an example workbook; in my previous example i had simplified the worksheet, as you will notice the example workbook is more complicated with odd blank lines turning up randomly which need deleting as they do not contain any information. All info under the date is one event, which makes life easier at least. As i said, any and all help is appreciated. I am glad there are forums like this to help.


    Thanks


    Matt

  • Re: Macro to copy and paste data between date&time code


    Hi Craig
    That sheet works fine (thanks for getting back in touch so quickly), however it is a bit difficult to include it given the other macros i have already written. Attached is a much more accurate data file, with macros that this problem needs to combine with, which will show my problem much clearer. In sheet 1 there is an option menu to sort the data, the two macros that need examining are 'clean data' and 'extract data', if you press 'clean data' then check the other three sheets you will see that some dates are highlighted (orange) are some other are not inbetween the predefined data extraction points (start extarction and end extraction). The extract data sheet extracts the orange highlights rows into another sheet ready for the other macros to do their jobs (i have had to delete these for file size reasons).


    What i need to be able to do is fit what you did in your macro, into my macro so instead of ignoring certain dates and only copying certain rows around the date (this is how data used to be set up), the oranged highlighted rows contain all the information from a certain date down to the next date, and this continues until it hits the 'end extraction' point currently located in column B. Essentially it is still the same problem, but much more complicated given that i am trying to get it to work with all the other macros that have been written so i dont have to write them again.


    Hope this all makes sense, and the file is zipped so that i could upload it. I have spent hours and hours trying to sort it out, and i am not too sure why i am making such a hash of it. If you jump into the 'clean data' macro i have made a note where the problem starts. (it simply say "!!!!!!Problem starts here!!!!!!")


    Kind regards


    Matt

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!