#1
|
|||
|
|||
VBA macro to copy range and paste in next blank row
I'm trying to copy a named range and paste it two rows below. I want to retain all the source formatting and formulas and include all cells whether they are blank or not. I want to repeat this macro based on the cell value from J5. Here's what I have.
Sub Copy_Paste() Dim i As Long For i = 1 To Range("J5") Range("oldroom").Copy Range("A" & Rows.Count).End(xlUp).Offset(2, 0).PasteSpecial xlPasteValues Next i End Sub It won't copy the blank rows. The named range includes 15 rows but it only copy/pastes the first two. The remaining rows have formulas but no values. This macro is supposed to allow the end user to enter a number in J5 to tell how many pages (each "oldroom" should be a page) to add. Additionally, I need the macro to insert a page break between each repeat of the macro. Any ideas? I've successfully tested the above macro by using it on a sheet with a simple 15 row, 3 column table with positive values in all representative cells, but it won't work on my template sheet where there are formulas and zero values aplenty. |
Tags |
add page breaks, copy blanks, repeat macro |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Paste Special: Copy and Paste Formatting Only? | tinfanide | Word | 6 | 03-06-2013 12:21 AM |
How to do an automation for copy paste, added new row (macro) | jpol | Excel Programming | 1 | 03-01-2013 05:53 AM |
how to cut and paste for the range | tomlam | Excel Programming | 5 | 12-26-2012 02:20 AM |
copy a range including shapes | Marcus | Excel Programming | 8 | 08-17-2012 01:50 AM |
How to remove blank rows from a specified range? | Learner7 | Excel | 1 | 04-19-2011 02:45 AM |