Copy values from one workbook to another with merged cells

  • Hi,


    I have a little problem with a code i'm using.


    I have 6 workbooks and one main workbook.
    The 6 workbooks are filled in by 6 different people, this is nto a problem.
    The main workbook is opened when a meeting starts, and with a click on a button all the info from the 6 other workbooks are put in the main sheet. This works pretty good, but with a few flaws.


    The cells that people fill in those 6 workbooks are merged cell ( for example G5:AA5 ), and that data is being copied to the main workbook also in merged cells ( for example G32:AA32 )
    All goes wel as long people stay within the width of the merge cells, if they go outside the width of the merge cells i get an error in the code. That happens also when they use ALT+Enter.


    I know working with merged cells is not the best option within excel, but can't yet find a different solution.


    The fix i like to have : copy the data in the main workbook, in the merged cells, without problems if the cell value is bigger then the merged cells.
    Hope somebody can help me.


    The codes I use are also found on boards, so credits goes to those people.



    The code for collecting the data:


    The code in a module to get the data from one workbook: the row giving a problem is commented


    Thanks for the assist.

  • Re: Copy values from one workbook to another with merged cells


    Try Using "Center Across Selection" rather than merged cells.


    unmerge cells > select the cells > Format Cells > Alignment > Horizontal > Center Across Selection

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: Copy values from one workbook to another with merged cells


    KjBox
    just tried it, but that doesn't work. Still get the "runtime error 13 - Type mismatch". It also doesn't makes the row heiger to fit the text, its stays at the same height.

  • Re: Copy values from one workbook to another with merged cells


    In that case, can you attach your workbooks, far easier to find a solution that way.
    [sw]*[/sw]

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: Copy values from one workbook to another with merged cells


    As previously mentioned, stay away from merged cells.
    However, if you feel like bucking the trend, try this.

    Code
    x = Range("B6").MergeArea.Cells(1, 1).Value
        Range("B15").MergeArea.Cells(1, 1).Value = x


    If you want to check all sheets and change merged areas to center across selection, you could try this.

  • Re: Copy values from one workbook to another with merged cells


    jolivanes
    Thanks for a possible solution, but where do I put this code in. Will that be instead of the arrays I use or is this a extra piece of code that I need.

  • Re: Copy values from one workbook to another with merged cells


    I can't reproduce your problem with this, ran from workbook "Main.xls", and both workbooks open.


    The code from Post #6 was something used in another problem with offset cells from merged cells.

  • Re: Copy values from one workbook to another with merged cells


    jolivanes
    sorry for the late response, just came back from a little trip.
    But that looks indeed in what i was looking for, thank you so much.
    I will try to adapt it to my worksheets, and hopefully my problems are gone.
    If not, I will be back :wink:

  • Re: Copy values from one workbook to another with merged cells


    jolivanes
    I mixed the codes ( the one I aleady was using, and the one you provided) and it got the whole thing working. Again thank you for your help.
    Happy holidays

Participate now!

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