Copy hidden row and paste unhidden after last row

Hudco

Board Regular
Joined
Jan 4, 2006
Messages
129
Office Version
  1. 365
Hi people,
I am trying to copy a row and paste it after the last row of data but retain only formula and no data. Have since found Excel won't do this so I have created a hidden row with the formula and no data.

This is row 5.

I then want to copy this row and paste or insert it below the last row with data. The cell A5 does not have a formula or data. The following is what I have but the new row is hidden. Any thoughts/help much appreciated.
VBA Code:
[CODE=vba]
    Rows("5:5").Select
    Selection.Copy
    Range("A5").Select
    Selection.End(xlDown).Offset(1, 0).Select
    Selection.Insert Shift:=xlDown
Thank you in anticipation
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
The cell A5 does not have a formula or data.
I have assumed then that B5 does and that column B can be used to determine the last row of data.
Try not copying the whole row, something like this.

VBA Code:
Sub Copy_Row()
  Range("A5:Z5").Copy Destination:=Range("B" & Rows.Count).End(xlUp).Offset(1, -1)
End Sub
 
Upvote 0
Solution
Do I understand you right that you want to copy the formula in Range A5 to the first empty cell below the used data in Column A?
You also mention to copy the Row but in your code in post #1 it only shows that single cell (A5)
How many cells to the right need to be copied/pasted?
 
Upvote 0
Upvote 0
I have assumed then that B5 does and that column B can be used to determine the last row of data.
Try not copying the whole row, something like this.

VBA Code:
Sub Copy_Row()
  Range("A5:Z5").Copy Destination:=Range("B" & Rows.Count).End(xlUp).Offset(1, -1)
End Sub
Hi Peter SSs,

On re-reading my original post is not overly clear. Your code worked - Thanks.
ps My apologies for the delayed reply - busy weekend.
 
Upvote 0

Forum statistics

Threads
1,223,956
Messages
6,175,609
Members
452,660
Latest member
Zatman

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