+ Reply to Thread
Results 1 to 18 of 18

keep source rows height during copy paste

  1. #1
    Forum Contributor
    Join Date
    04-21-2010
    Location
    Budapest
    MS-Off Ver
    Excel 2010
    Posts
    155

    keep source rows height during copy paste

    I have a code for copy from source to target the values, formats, and column width. Unfortunately this process can't keep the height of the rows from the source to the target worksheet.

    I found some short code but i can't implement in my existing code:

    Please Login or Register  to view this content.
    My original macros:
    Please Login or Register  to view this content.
    Last edited by ccsmith; 11-03-2012 at 03:32 PM.

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: keep source rows height during copy paste

    Hello ccsmith,

    Try it like this;

    Please Login or Register  to view this content.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Forum Contributor
    Join Date
    04-21-2010
    Location
    Budapest
    MS-Off Ver
    Excel 2010
    Posts
    155

    Re: keep source rows height during copy paste

    unfortunately the your suggestion don't work.
    Isn't there any special xlpaste commend for row height?
    In the following part should be insert a command which can keep the height of the rows from the source sheets.

    Please Login or Register  to view this content.

  4. #4
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: keep source rows height during copy paste

    See the attached sample WorkBook complete with code, and try to implement it in your project.

    If you still have a problem, then upload a sample of your WorkBook, so that I can see how to help.
    Attached Files Attached Files

  5. #5
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: keep source rows height during copy paste

    Sorry, just noticed that you are using Excel 2003.

    See attached WorkBook for same.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    04-21-2010
    Location
    Budapest
    MS-Off Ver
    Excel 2010
    Posts
    155

    Re: keep source rows height during copy paste

    Thanks for your sample file. I tied to implement without success.
    Therefore I upload my sample file. Please help me to modify the code to I can keep the height of rows as well in the new sheet.
    Attached Files Attached Files

  7. #7
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: keep source rows height during copy paste

    There are a few lines of code that I do not know what you are trying.

    I have placed comments next to some lines for your information.

    Try the attached Workbook now.

    Hope you are happy with it.
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    04-21-2010
    Location
    Budapest
    MS-Off Ver
    Excel 2010
    Posts
    155

    Re: keep source rows height during copy paste

    Thanks for your answer but it isn't working in the way I need.
    The original file do the followings:
    - from sheet4 row 6 the data go to arrays in sheet2 filling the cells
    - from sheet2 the filled chart must copy to sheet3 (with values, column width, formats, row heights)
    - from sheet4 row 7 the data go to arrays in sheet2 filling the cells
    - from sheet2 the filled chart must copy to sheet3 (with values, column width, formats, row heights) under the last filled row (r = r + 16)
    and so on.
    Please run the macro in the attached file and see the result in sheet3
    The macro is working fine but I don't find the solution to copy the row height from sheet2 to sheet3 not just only range A1:G16.

  9. #9
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: keep source rows height during copy paste

    O.k. Now for the Bad news. I found Merged Cells, and that causes a myrid of problems, especially when you are trying to copy and paste, and the Cells in play are not identically Merged or sized.

    I have removed the Merged Cells, and changed the Code to Copy the UsedRange from Sheet2 to Sheet3.

    If that works for you, then I am happy. All you have to do is Uncomment the Code you still require with regards to the other steps of your Project.
    Attached Files Attached Files

  10. #10
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: keep source rows height during copy paste

    @ccsmith

    Please dont create 2 threads for the problem the same day.

    I created a solution at your other post http://www.excelforum.com/excel-prog...html?p=2993685
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  11. #11
    Forum Contributor
    Join Date
    04-21-2010
    Location
    Budapest
    MS-Off Ver
    Excel 2010
    Posts
    155

    Re: keep source rows height during copy paste

    Winon. Thanks for your effort but unfortunately it is not working like I need.
    Original file (attached sample5.xlsx) is working fine. It can copy the range by range to sheet3 with merged cell as well.
    The only problem is that don't keep the row height.
    I should copy range from sheet2 with format, row height, column width format and values to sheet3 then fill sheet2 again with new data and copy on sheet3 below the first copied range.
    Please check the result on sheet3 in my sample file where you can check the result and the problem with the row height.
    Attached Files Attached Files

  12. #12
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: keep source rows height during copy paste

    Then try this one.
    Attached Files Attached Files

  13. #13
    Forum Contributor
    Join Date
    04-21-2010
    Location
    Budapest
    MS-Off Ver
    Excel 2010
    Posts
    155

    Re: keep source rows height during copy paste

    Sorry to say but it is not good. No problem.
    Do you have solution for the following?
    I want to set the row height of row: 10; 11; 12; 13 to value 30.
    and each row below these ones with steps 16 ie:
    rows 10+16= 26; 27; 28; 29
    rows 26+16= 42; 43; 44; 45
    and so on as far as the last row contains value End(xlUp).

  14. #14
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: keep source rows height during copy paste

    Give this a try

    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    04-21-2010
    Location
    Budapest
    MS-Off Ver
    Excel 2010
    Posts
    155

    Re: keep source rows height during copy paste

    Many thanks for your all effort.
    With your last solution I set the height of each row to the preferred one.
    Thanks for your toleration toward to me.

  16. #16
    Forum Contributor
    Join Date
    04-21-2010
    Location
    Budapest
    MS-Off Ver
    Excel 2010
    Posts
    155

    Re: keep source rows height during copy paste

    Just one more request:
    When the macro find an empty cell it gives a error code: Subscript out of range.
    Can you add a line to skip the empty cell and go to the next cell.
    Please Login or Register  to view this content.

  17. #17
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520
    What column has the empty cell? Is the whole row empty? How do you know its an empty cell giving the error?

  18. #18
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520
    Have you changed the layout of sheet 2. Did you unmerge cells?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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