+ Reply to Thread
Results 1 to 19 of 19

Merge rows by condition from one workbook to another

  1. #1
    Registered User
    Join Date
    01-27-2012
    Location
    Blankenberge, Belgium
    MS-Off Ver
    Excel 2003
    Posts
    28

    Merge rows by condition from one workbook to another

    Hereby the file:
    Datarapport.xls

    From within this file its workbook, i copy a selection of rows to another workbook using this script:

    Please Login or Register  to view this content.
    Within the sourcefile the first field has a unique id. Upon the copy-process mentioned above, i would like excel to merge the rows that have the same unique id, meaning, if A2 = A3, they merge. Regarding the other columns: the data of the first column of the merge may be saved, other merged data is to be lost.

    Thank you in advance.
    Last edited by WilliamV; 02-09-2012 at 11:32 AM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Merge rows by condition from one workbook to another

    Hi WilliamV
    you will some sensibility checks to make sure the word book does have a Datarapport

    But advance filter makes life easy

    Please Login or Register  to view this content.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Registered User
    Join Date
    01-27-2012
    Location
    Blankenberge, Belgium
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Merge rows by condition from one workbook to another

    Pike, thank you, i will give this a try tomorrow and post my findings.

    Could you inform me a bit further upon
    some sensibility checks
    What checks need to be done and how. What do you recommend (based upon your own experience) ?

    Based upon the merging process of the rows, depending on the first cell (A1) is it possible to hide that cell (with the unique id) in the new generated file? This because the end-user does not need to know this id.

    Thank you in advance!

  4. #4
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Merge rows by condition from one workbook to another

    Hi WilliamV
    probably just to make sure this
    Please Login or Register  to view this content.
    exist in the opened workbook

  5. #5
    Registered User
    Join Date
    01-27-2012
    Location
    Blankenberge, Belgium
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Merge rows by condition from one workbook to another

    I populate the data in an existing Worksheet called Datarapport. So that is ok.
    Thank you!
    Last edited by WilliamV; 01-30-2012 at 05:38 AM.

  6. #6
    Registered User
    Join Date
    01-27-2012
    Location
    Blankenberge, Belgium
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Merge rows by condition from one workbook to another

    This code returns an automatisation error.
    Hereby my full code:

    Please Login or Register  to view this content.
    Hereby the files:
    Kopie van Datarapport.xls
    Datarapport-filter-UiTagenda.xls

    The first file is the source file, the second the filter file containing the VBA.

    Could you trace the inoccurrencies and help me further? Thx!

  7. #7
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Merge rows by condition from one workbook to another

    Try...
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    01-27-2012
    Location
    Blankenberge, Belgium
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Merge rows by condition from one workbook to another

    Pike, that does the job!

    But how do i use this code together with above mentioned code (the copy of only specific ranges) ?

  9. #9
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Merge rows by condition from one workbook to another

    oh
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    01-27-2012
    Location
    Blankenberge, Belgium
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Merge rows by condition from one workbook to another

    Pike, I still get an automisation error.
    Maybe I need to include the A-column on which the merge-proccess applies?
    Please advise.

  11. #11
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Merge rows by condition from one workbook to another

    yes
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    01-27-2012
    Location
    Blankenberge, Belgium
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Merge rows by condition from one workbook to another

    I still get an automatisation error.

    Here is my code:

    Please Login or Register  to view this content.
    And here is a screenshot of the error message:
    ScreenShot002.jpg.

    Thank you and regards,

  13. #13
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Merge rows by condition from one workbook to another

    Ik denk niet dat Pikes Nederlands al zo goed is dat hij dit begrijpt.

    You could:
    - open te workbook
    - copy the worksheet so that a new workbook is being created
    - adapt the data in the new workbook.

    You'd better not specify a criterion range:

    Please Login or Register  to view this content.



  14. #14
    Registered User
    Join Date
    01-27-2012
    Location
    Blankenberge, Belgium
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Merge rows by condition from one workbook to another

    Here is a code that does the job, but i don't know if it's bulletproof.

    Please Login or Register  to view this content.
    Here all required data is gathered in the worksheet, then duplicates from range A are deleted (whole row). The duplicate deletion code i found on this website.
    Thsi is an intensive process if need to be applied to lots of data.

    How to accomplish this with the Advanced filter in VBA?
    Thank you.
    Last edited by WilliamV; 01-31-2012 at 10:37 AM.

  15. #15
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Merge rows by condition from one workbook to another

    snb's idea is better
    copy the worksheet to the workbook and then work with it

  16. #16
    Registered User
    Join Date
    01-27-2012
    Location
    Blankenberge, Belgium
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Merge rows by condition from one workbook to another

    Ok, thank you!
    As you must have noticed, i don't have any VBA-code experience, just beginning to learn and most of all: trying to understand every step.

    The code as it is right now (my latest post) seems to do the work so i'll hang on to that.

    Just one question about following code snb helped me with:
    to split the time in cell A1 to cell B1 and C1:
    Please Login or Register  to view this content.
    This code needs to apply to the G-column (G2:G). So time-data from this column needs to be exported to G and H-columns. How top adapt this code doing that?

    Now my other concern is to offer the end user the ability to create a selection of rows (with checkboxes?) and then (by pushing a button?) export those rows to a new file. Can you assist on this as well or is it preferable i start a new thread?

    Thx.

    Thank you.

  17. #17
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Merge rows by condition from one workbook to another

    As you must have noticed, i don't have any VBA-code experience, just beginning to learn and most of all: trying to understand every step
    In that case you better start at the beginning: a course, a book.
    VBA is a language you have to learn pretty much like any other language: do not start with complicated poems, but with simple, everyday words & sentences.

  18. #18
    Registered User
    Join Date
    01-27-2012
    Location
    Blankenberge, Belgium
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Merge rows by condition from one workbook to another

    @snb: I will do that. Thank you for the advice.

    In the meanwhile: can you or someone else help me with my questions in the post above:
    - splitting time
    - create checkboxes and let users export the file to a new one?

    Thank you.

  19. #19
    Registered User
    Join Date
    01-27-2012
    Location
    Blankenberge, Belgium
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Merge rows by condition from one workbook to another

    I used some vba and some formula's. Works nice. Thank you for all your help and i'll continue reading my book. In the meanwhile i hope i can count on your help on future issues. Thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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