ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Copy, Paste and Rename a Range using a macro (https://www.excelbanter.com/excel-discussion-misc-queries/183759-copy-paste-rename-range-using-macro.html)

[email protected]

Copy, Paste and Rename a Range using a macro
 
I have been attempting to copy, paste and rename a range using an
Excel macro. I have a specific line that I want the new range copied
to in each instance (a line with a named range for a cell) and so far
I have this:

Sub Add_Task()
'
' Add_Task Macro
'

'
Range("Task1").Select
Selection.Copy
Range("LaborTotals").Offset(-1, 0).Select
Selection.Insert Shift:=xlDown
End Sub

I cannot get the range to rename and I cannot get a blank row between
the first range and the second. Can someone assist? Thanks.

nathan_savidge

Copy, Paste and Rename a Range using a macro
 
Hi,

What you need to do is make the name of the range dynamic. Go to Insert --
Name and then define. Name your range "Labour Totals"

And then in the refers to:

=OFFSET($A$1,0,0,COUNTA($A:$A),1)

or what ever the left column of the range is.

" wrote:

I have been attempting to copy, paste and rename a range using an
Excel macro. I have a specific line that I want the new range copied
to in each instance (a line with a named range for a cell) and so far
I have this:

Sub Add_Task()
'
' Add_Task Macro
'

'
Range("Task1").Select
Selection.Copy
Range("LaborTotals").Offset(-1, 0).Select
Selection.Insert Shift:=xlDown
End Sub

I cannot get the range to rename and I cannot get a blank row between
the first range and the second. Can someone assist? Thanks.



All times are GMT +1. The time now is 01:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com