+ Reply to Thread
Results 1 to 29 of 29

Copy Paste Between workbooks, Sort, Formulas Filling.

  1. #1
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Copy Paste Between workbooks, Sort, Formulas Filling.

    Hi
    I am looking for a macro to automate my work now done manually. I use WB2 sheet "Pasteboard" to paste data from WB1, clean it up, format it, then paste into sheets 1-4, sort them and fill down formulas.

    Specifically I would like the macro to:

    In WB2 sheet1 and sheet2 INSERT indicated columns of records whose FROM column in WB1 match "1234" in A19 (shift cells down).
    Then in sheet1 sort the inserted records per columns BCD.
    Then in sheet1 copy down formula in I18 to the dotted line row, not included.
    Then in sheet 2 copy down formulas i17:n17 to the dotted line row, not included.
    Then in sheet 2 sort inserted records (between rows with dotted lines) per JBC
    Columns G and H entries should be numbers, not numbers entered as text.

    Repeat for sheet3 and sheet4, BUT for records whose FROM column in WB1 match "5678"


    Note: There is nothing I can do for the structure of WB1. I get it as is. It may contain hundreds of records.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    Hello,

    macro "test" in WB1 L2
    extra hidden sheet "blad1" in WB2L

    the sort part is not done, i dont see the BDC or JBC


    Kind regards
    Leo
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    Thank you very much LEO for time spent for me!

    BCD or JBC represent columns in WB2. (BDC = sort per column B, then C, then D).

    I will report as soon as I get to the file location (I am now mobile).

    A couple of things:

    1. Although the structure remains the same, every time they send me a WB1, the file has a different name.
    2. The macro, I think, needs to be in WB2 because it is the destination file and after the macro is run, the file can be Saved As...

    Because of #1 above, I can either take the file in temp directory and rename it, or have the macro work off open files (have both WB1 and WB2 open at the same time).

    What do you suggest?

    edit: Manually selecting the WB1 range to be imported into WB2 is fine too, if you can get the macro to work from the clipboard data. However, I do not know if this is the best approach...
    Last edited by drgkt; 12-24-2015 at 04:48 AM.

  4. #4
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    1 way is as follow

    copy the compleet sheet from wb1 to wb2 sheet "PasteBoard"
    now from wb2 run macro "test2"


    Kind regards
    Leo
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Copy Paste Between workbooks, Sort, Formulas Filling.

    Unfortunatelly...

    In sheet1 of WB2
    a18:a23 no grid
    Duration, Ext.Duration,Volume and Amount not converted to time / number.
    Dotted line (that should have been in I19; sorry*) has been overwritten instead of being moved to I23.
    First record for receiver 9000 is not inserted. (I only copied the data, not the headings row into "Pasteboard").

    * I also right copied the dotted line:
    Sheet2 to N19
    Sheet3 to I19
    Sheet4 to N19

    IMPORTANT: Elsewhere in sheets there are formulas like sum(I18:I19) which after the data insertion in this case must change to sum(I18:I23).
    When I manually do it, I use control right click on A19 - Insert Copied Cells - Shift Cells down. This insures the formula change.

    REMINDER: Excel XP (2002)
    Attached Images Attached Images
    Last edited by drgkt; 12-25-2015 at 06:20 AM.

  6. #6
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    copy sheet to PasteBoard with headers

    for the sort part i can not help, it is working here (version 2007)
    so that part i leave to someone with experiance in excel 2002

    and see if other items are ok now


    Kind regards and happy Xmas

    Leo
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    Merry Christmas and Happy New Year to you too!

    Here is some info on the 438 error. Unfortunatelly, it is ...greek to me!: http://answers.microsoft.com/en-us/o...09cb375?auth=1

    downloading now...

    1. Although copied and pasted only FROM 1234, data is pasted to sheet3 & 4. It should not.
    2. a17:a23 no gridlines.
    3. data not inserted between dotted lines
    4. duratiom, ext.duration is left as text.
    5. test formula in sheet 1 e15 =sum(e18:e19) cahnges to sum(e18:e18) instead of (e18:e23)
    Last edited by drgkt; 12-25-2015 at 12:29 PM.

  8. #8
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    best thing to do

    post exemple before with formula (not text "formula") and exemple after

    Kind regards
    Leo

  9. #9
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    Before and after uploaded.
    Check comments on every sheet.

    Hope you had a nice Christmas day.
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    TIP (if of any help)
    When I manually INSERT, to ensure that in sheets 2 and 4 J19:N19 also shift down, in "Pasteboard" I select / copy 6 empty columns to the right of usefull data. (See selection in "Pasteboard")
    I insert those in sheet 1 and 2, then do the same for the other data whose "FROM" = "5678" and insert in sheets 3 and 4.
    Attached Files Attached Files

  11. #11
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    maybe it is ok now
    gridded lines fixed in wb1

    Kind regards
    Leo
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    Almost...

    1. Records whose "FROM" field = "1234" should be inserted in sheets 1 and 2, not 1 and 3. Records whose "FROM" field = "5678" should be inserted in sheets 3 and 4, not 2 and 4.
    2. If I pick ONLY records whose "FROM" field is "1234" OR "5678", I get Run time error 1004: Application or object defined error. Sheets("sheet1").Range("A19").Resize(at, 9).Insert shift:=xlDown
    The difference is that the "1234" records get inserted while the "5678" records do not.

  13. #13
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    See comments in each sheet.

    I put my 2 cents in code --> .ClearFormats
    Attached Files Attached Files

  14. #14
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    some day we get there

    next try


    Kind regards
    Leo
    Attached Files Attached Files

  15. #15
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    I am sure you 'll nail it!

    The RECEIVER in all 4 sheets should be pasted as text, otherwise leading zeros may get lost or x.xxxE+11 show up.

    I am loosing the bottom dotted lines when I paste more than the sample records shown in WB1, but the formulas seem to update ok.

  16. #16
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    Up to 10 or not
    next try

    Kind regards
    Leo
    Attached Files Attached Files

  17. #17
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    Here is an issue.
    Like I said before, when I insert more records, for some reason the bottom dotted lines are lost BUT ONLY for colums A through H.
    In other words in sheet 2 A452:H452 are blank but I452:N452 is dotted lines.

    In sheet 2 there was an array formula {=SUM(1/COUNTIF(D18:D19;D18:D19))-1} which correctly changes to {=SUM(1/COUNTIF(D18:D452;D18:D452))-1}. D18 is dotted lines, D452 is blank. Because of this the formula value turns to #DIV/0!. As soon as I put dotted lines in D452, it gives me the correct result.

    What do you think?

  18. #18
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    No idea wy that happend
    in this one for each sheet 1 copy order more in code for dotted line, hope that will do it


    Kind regards
    Leo
    Attached Files Attached Files

  19. #19
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    In this sample, dotted lines are not applied in:
    Sheet1: I452
    Sheet2: I452:J452
    Sheet3: I165
    Sheet4: I165:J165

    Run it
    Attached Files Attached Files

  20. #20
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    It is a hard one, nice


    Kind regards
    Leo
    Attached Files Attached Files

  21. #21
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    But not hard enough for LEOOOOO!!!!!!
    Bravooooo!

    The only thing left is the sorting of data between the dotted lines: Sheets 1 and 3 per columns BCD, sheets 2 and 4 per columns JBC, all ascending, data contains no headings.

    It can be a different macro to run after this one.

  22. #22
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    hope this time the sort works on your version
    here it does

    Kind regards
    Leo
    Attached Files Attached Files

  23. #23
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    Unfortunately, I get error 438 --> "ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear". Does this help?

    I told you what to sort BY but not exaxtly WHAT.

    Sheets 1,3 sort data in columns A thtough H
    Sheets 2,4 sort data in columns A through J
    (Sheets 1 and 3 have no data in I and J below row 18, so I guess you can use A through J for all to reduce coding).

    As you know in all 4 sheets data starts on A19.
    Last row is dotted lines, so when I manually do it, I hit shift - end - down and back one row up.

  24. #24
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    Think this way it works also in Excel 2002

    Kind regards
    Leo
    Attached Files Attached Files

  25. #25
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    It sure does!!!
    Excellent!!!
    You saved me lots of key strokes!
    THANK YOU VERY MUCH

    P.S. Where do I start learning this?

  26. #26
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    best place to learn is here
    the practise to find solutions for questions from other users is a very good school

    thats the way i learn it

    Kind regards
    Leo

  27. #27
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    Columns G, H are coming in as text when I tried it on another machine running office 2003 in Greek.

    Cannot figure out why in 2002 english are coming in as numbers but in 2003 Greek are coming in as text. I checked the decimal separator setting in tools options, is set ok as per WB1 (comma for decimal).

  28. #28
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    this tread is marked as solved, so better start a new one like i suggest before

    Kind regards
    Leo

  29. #29
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Re: Copy Paste Between workbooks, Sort, Formulas Filling.

    Marked it Unsolved, this way we keep all in one place rather than repeating...

+ 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. Macro to copy formulas from multiple workbooks into new workbook (paste text of formula)
    By robertsfd2002 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-24-2014, 12:46 PM
  2. [SOLVED] Open Multiple Workbooks, Record names, Copy paste to Active Workbook, Close the Workbooks
    By vba_madness in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-24-2013, 06:09 AM
  3. Creating a loop that will sort, copy, paste and save data into seperate workbooks
    By EggHead in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-14-2009, 03:17 PM
  4. Paste formulas without auto filling
    By naquer in forum Excel General
    Replies: 7
    Last Post: 09-28-2009, 04:13 AM
  5. How do I copy and paste formulas between workbooks?
    By tezza in forum Excel General
    Replies: 4
    Last Post: 07-06-2006, 02:00 PM
  6. During filling Excel Sheet copy/paste in Explorer does not work
    By Joerg Battermann in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-28-2005, 12:05 PM
  7. [SOLVED] Filling Formulas Across Workbooks
    By BClifft in forum Excel General
    Replies: 1
    Last Post: 04-22-2005, 04: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