Copy Cell Height

Noz2k

Well-known Member
Joined
Mar 15, 2011
Messages
693
I have a range of cells which are copied and then pasted at the bottom of a sheet. However the cell height is not being copied. Which means that the cells in the pasted range look very clustered and also do not fill a page as I would like.

This is the code I am currently using

Code:
 Sheets("Report").UnProtect Password:="Password"
    Range("A220:N264").Select
    Selection.Copy
    Range("A265:N309").Select
    Selection.EntireRow.Hidden = False
    ActiveSheet.Paste
    ApplicationCutCopyMode = False
    ActiveSheet.PageSetup.PrintArea = "$A$1:$N$309"
    ActiveSheet.HPageBreaks.Add Before:=Range("A265")

What do I need to add, to ensure that the cell height is always copied?
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Where would be the best place to put this, because it doesn't seem to be doing the trick unfortunately
 
Upvote 0
A little bit more of the code, in case it makes a difference.

Code:
Dim cl As Range
Dim clMerge As Range
 
    Range("A265").EntireRow.Hidden = True Then
    Sheets("Report").UnProtect Password:="Password"
    Range("A220:N264").Select
    Selection.Copy
    Range("A265:N309").Select
    Selection.EntireRow.Hidden = False
    ActiveSheet.Paste
    ApplicationCutCopyMode = False
    ActiveSheet.PageSetup.PrintArea = "$A$1:$N$309"
    ActiveSheet.HPageBreaks.Add Before:=Range("A265")
    Range("D268") = "2"
    Sheets("Sheet5").Protect Password:="Password"
        For Each cl In Sheets("Report").Range("A265:N309").Cells
                            If cl.Locked = False Then
                                If cl.MergeCells = True Then
                                    Set clMerge = Range(cl.Address).MergeArea
                                    clMerge.ClearContents
                                Else
                                    cl.ClearContents
                                End If
                            End If
                                Next cl


Still can't get this going, so any help would be greatly appreciated
 
Upvote 0
After

Code:
ActiveSheet.Paste

Maybe

Code:
Range("A265:N309").Rows.AutoFit

Will get it close and then you could add a simple loop like

Code:
For i = 265 To 309
      Rows(i).RowHeight = Rows(i).RowHeight + 2
Next i

To increase the height a little bit.

Or maybe a loop like

Code:
For i = 220 to 264
      Rows(i+45).RowHeight = Rows(i).RowHeight
Next i

Would work.
 
Upvote 0
Thanks,

That was the first place I tried it, but whilst it ran fine, it didn't seem to make any difference.

The problem with the other solutions is that within the range there are various heights for different rows.
 
Upvote 0
Doesn't this duplicate the row heights?


For i = 220 to 264 Rows(i+45).RowHeight = Rows(i).RowHeightNext i</PRE>
 
Upvote 0
Yes it does!

My understanding of that code was wrong on first reading. I thought it was just increasing the row height of every cell. (I forgot that the range contained 45 rows)

This has been frustrating me all day, so thank you very much for helping me out :)
 
Upvote 0

Forum statistics

Threads
1,224,557
Messages
6,179,504
Members
452,917
Latest member
MrsMSalt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top