+ Reply to Thread
Results 1 to 27 of 27

Copying Specific Data sets and pasting them in Columns of 10

  1. #1
    Registered User
    Join Date
    03-11-2015
    Location
    the dirty south
    MS-Off Ver
    Ms office 2011
    Posts
    36

    Copying Specific Data sets and pasting them in Columns of 10

    Hello All,

    I'm having trouble writing out a code to organize some data I have in a specific way. I must preface by saying I am a novice.

    The Problem:
    So I receive an exported excel file that gives me data in the same format every time. There is only 1 piece of information I need from the data I receive and that is the Distance traveled, but I need this data organized by the genotype I am testing. This data must also be organized in sets of 10 and these columns of 10 data points must be placed directly next to each other in order to calculate the data.

    Heres some pictures of what I need if my explanation was not clear:
    This is the data I recieve
    Picture2.jpg
    and I want the data to look like this (minus the bold numbers)
    Picture1.jpg
    Note: The data that is shown here is only the distance travel, which is the only data I need extracted

    The attempt:
    I was using a code that was given to me by Alf and I was trying to modify it to this purpose but I was unable to get it to work heres what I have thus far:
    Please Login or Register  to view this content.
    Last edited by novious1; 04-12-2015 at 10:06 PM.

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Copying Specific Data sets and pasting them in Columns of 10

    It would be easier if you sent a sample of the input data as well as its matching expected results in an excel file.

  3. #3
    Registered User
    Join Date
    03-11-2015
    Location
    the dirty south
    MS-Off Ver
    Ms office 2011
    Posts
    36

    Re: Copying Specific Data sets and pasting them in Columns of 10

    Here's an example of what I want. Sheet 1 shows how the data is exported and sheet 2 shows how I would like the data organized
    ExampleTimedata.xlsx
    Thanks for any help

  4. #4
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Copying Specific Data sets and pasting them in Columns of 10

    run the macro. the output is recorded in sheet3
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-11-2015
    Location
    the dirty south
    MS-Off Ver
    Ms office 2011
    Posts
    36

    Re: Copying Specific Data sets and pasting them in Columns of 10

    Hi rcm thanks for your input, but its not exactly what I need. I need only the distance traveled for each data set not the velocity. Also the data has to be organized where all the genotypes ie) all the Canton-S data are placed next to each other. So each column of 10 data points is next to another column of 10 data points from canton-s.

  6. #6
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Copying Specific Data sets and pasting them in Columns of 10

    My bad. Ill fix in a second..

  7. #7
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Copying Specific Data sets and pasting them in Columns of 10

    Take a look at it now!
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    03-11-2015
    Location
    the dirty south
    MS-Off Ver
    Ms office 2011
    Posts
    36

    Re: Copying Specific Data sets and pasting them in Columns of 10

    It works beautifully!!!!. I have to ask though will this work if I have more than 3 genotypes? Also if you dont mind could you walk me through your code for learning purposes.
    THANK YOU so much again

  9. #9
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Copying Specific Data sets and pasting them in Columns of 10

    Please Login or Register  to view this content.
    If you have any more questions, (ah yeah it will work for n groups), please feel free to ask...

  10. #10
    Registered User
    Join Date
    03-11-2015
    Location
    the dirty south
    MS-Off Ver
    Ms office 2011
    Posts
    36

    Re: Copying Specific Data sets and pasting them in Columns of 10

    I do have a few more questions (sorry). I am importing these data from different files is there a way to add this into the code as well. I tried to add this to your code in order to do this but it didnt really work heres my attempt.
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    03-11-2015
    Location
    the dirty south
    MS-Off Ver
    Ms office 2011
    Posts
    36

    Re: Copying Specific Data sets and pasting them in Columns of 10

    I probably should clarify. I am adding data from several different files and I would like it if possible to have all the data from the different sheets compiled together into one worksheet.

  12. #12
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Copying Specific Data sets and pasting them in Columns of 10

    In order to further help, I need to know more

    All the *.xlsx files in the directory contain the data and need to be transferred.
    what is the structure in each file the same as the output file?
    is the data organized by groups too?

  13. #13
    Registered User
    Join Date
    03-11-2015
    Location
    the dirty south
    MS-Off Ver
    Ms office 2011
    Posts
    36

    Re: Copying Specific Data sets and pasting them in Columns of 10

    Yes all files are the same as the example data I had posted. I would like the data to be organized in the same way as before. It would just be a continuation of the same process.

  14. #14
    Registered User
    Join Date
    03-11-2015
    Location
    the dirty south
    MS-Off Ver
    Ms office 2011
    Posts
    36

    Re: Copying Specific Data sets and pasting them in Columns of 10

    So I was playing around with this today. I found a piece of code that will import the data, but i get an error code: Runtime-9 Error Subscript out range. Ill also post what I have so far using your code rcm
    Please Login or Register  to view this content.
    so what Im trying to do is select all the data and have it pasted in sheet1 one after the next that way I can use your code to sort and sequence it on sheet 3.
    Thanks for any help

  15. #15
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Copying Specific Data sets and pasting them in Columns of 10

    I think a good programming principle is that you use routines...

    The reason to call format after all the data has been transfered is tha format will read the whole thing...

    The fetching of the data should be done with a DIR loop to gather all the data from all the files in the specified directory (Thepath)

    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    03-11-2015
    Location
    the dirty south
    MS-Off Ver
    Ms office 2011
    Posts
    36

    Re: Copying Specific Data sets and pasting them in Columns of 10

    I copied your suggestion into the original code you had sent me and I got no result. I'm not sure if I am understanding you, are you saying I should have a folder where all the data is imputed and vba just accesses the data from that specific folder

  17. #17
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Copying Specific Data sets and pasting them in Columns of 10

    My suggestion was just a sketch or the structure of things.

    Either you have all the files in one common folder or you have a list full path included so it can read it from. I can help you write the full code either one. Send one sample of the original files to be appended and I will write the code from there.

  18. #18
    Registered User
    Join Date
    03-11-2015
    Location
    the dirty south
    MS-Off Ver
    Ms office 2011
    Posts
    36

    Re: Copying Specific Data sets and pasting them in Columns of 10

    Ahh ok I see. Yes I will have all the files placed into a common folder.Example data .xlsx The attached folder is on of many that have to be imported. I was also thinking about using a solution that another user Alf had given to me on a separate question I asked.
    Please Login or Register  to view this content.
    I was unable to get this to work for multiple files however

    Thank you for your help thus far!

  19. #19
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Copying Specific Data sets and pasting them in Columns of 10

    I coded a very simplistic routine that reads from a folder all normal files and places the pertinent data in sheet(1) of each file in sheet(3) of this workbook

    please adjust the path to your needs

    ah.. the routine call format at the end to extract the data and place it neatly in sheet2.

    When trying it out make sure that both sheet2 and sheet3 are empty
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    03-11-2015
    Location
    the dirty south
    MS-Off Ver
    Ms office 2011
    Posts
    36

    Re: Copying Specific Data sets and pasting them in Columns of 10

    It imports very nicely
    Heres what I have so far. I added a few things to speed it up a bit, but I keep getting a clipboard message saying if I want to keep all the copied data, its not a big deal just kind of annoying to see pop up.

    I do have a problem though, the code you originally wrote for me, from post #7, isnt working now its over writing itself.
    Please Login or Register  to view this content.
    Last edited by novious1; 04-13-2015 at 08:21 PM.

  21. #21
    Registered User
    Join Date
    03-11-2015
    Location
    the dirty south
    MS-Off Ver
    Ms office 2011
    Posts
    36

    Re: Copying Specific Data sets and pasting them in Columns of 10

    After stepping through the code several times I got it to work perfectly. Sorry for asking a dumb question in the post above.
    Heres what I did
    I changed
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Now I have to ask is there a way to display the name of the file above the data. Like in row A it marks the begging of each files data, by displaying the files name.

  22. #22
    Registered User
    Join Date
    03-11-2015
    Location
    the dirty south
    MS-Off Ver
    Ms office 2011
    Posts
    36

    Re: Copying Specific Data sets and pasting them in Columns of 10

    The shameless Bump...

  23. #23
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Copying Specific Data sets and pasting them in Columns of 10

    yes there is, Ill walk you through..
    .
    Please Login or Register  to view this content.

  24. #24
    Registered User
    Join Date
    03-11-2015
    Location
    the dirty south
    MS-Off Ver
    Ms office 2011
    Posts
    36

    Re: Copying Specific Data sets and pasting them in Columns of 10

    Hi rcm,

    I pasted the code, but I get the error Method 'Range' of object '_Global' failed. Thank you again for all your help thus far!

  25. #25
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Copying Specific Data sets and pasting them in Columns of 10

    try... the error has something to do with rmax, rwk, sorry but I have not runned through,,


    Please Login or Register  to view this content.

  26. #26
    Registered User
    Join Date
    03-11-2015
    Location
    the dirty south
    MS-Off Ver
    Ms office 2011
    Posts
    36

    Re: Copying Specific Data sets and pasting them in Columns of 10

    I probably should clarify I need the file information on sheet 3 above the already sorted data, in row 2 if possible. After that the code would be perfect

  27. #27
    Registered User
    Join Date
    03-11-2015
    Location
    the dirty south
    MS-Off Ver
    Ms office 2011
    Posts
    36

    Re: Copying Specific Data sets and pasting them in Columns of 10

    I probably should clarify I need the file name information on sheet 3 above the already sorted data, in row 2 if possible. After that the code would be perfect

+ 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. Copying data from a row with many columns and pasting with column rearranged
    By ivector in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-03-2014, 07:20 AM
  2. [SOLVED] Copying Data from Pivot and pasting it to specific location
    By dinesh_ltjd in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-22-2014, 06:46 PM
  3. [SOLVED] Macro for copying data from sheet1 and pasting to another when specific conditions are met
    By MathewPol in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-04-2014, 10:00 AM
  4. Copying Specific Data from One Workbook and Pasting to Another
    By dgarant in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-06-2012, 09:17 PM
  5. VBA Macro Help: Copying and pasting data that is date specific
    By bleedUTorange in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-03-2011, 02:00 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