ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy / Paste Easy (https://www.excelbanter.com/excel-programming/368466-copy-paste-easy.html)

willwonka

Copy / Paste Easy
 
I am trying to do a simple Copy/Paste

cLastcol = Sheets("Initial by Laser").UsedRange.Columns.Count
cLastRow = Columns("A:A").Find(What:="Grand Total",
LookAt:=xlWhole).Row

I want to copy "D" &clastrow+1: "D"&clastrow+17 to E+clastrow+1:
clastcol-5&clastrow+1
(In other words... D172:D192 to e172:ca192)

My sad attempt at code below:



Range("D" & cLastRow + 1 & ":" & "D" & cLastRow + 17).Copy
Range(Columns(cLastRow + 1, cLastcol - 5))


Dave Peterson

Copy / Paste Easy
 
cLastcol = Sheets("Initial by Laser").UsedRange.Columns.Count
cLastRow = Columns("A:A").Find(What:="Grand Total", LookAt:=xlWhole).Row

with worksheets("initial by Laser")
.range(.cells(cLastrow+1,"D"),.cells(clastrow+17," D")).copy _
destination:=.cells(clastrow+1,"E")
end with

Excel will resize the destination range to match the size of the copied range.

All this is happening on the "initial by laser" worksheet, right?


willwonka wrote:

I am trying to do a simple Copy/Paste

cLastcol = Sheets("Initial by Laser").UsedRange.Columns.Count
cLastRow = Columns("A:A").Find(What:="Grand Total",
LookAt:=xlWhole).Row

I want to copy "D" &clastrow+1: "D"&clastrow+17 to E+clastrow+1:
clastcol-5&clastrow+1
(In other words... D172:D192 to e172:ca192)

My sad attempt at code below:

Range("D" & cLastRow + 1 & ":" & "D" & cLastRow + 17).Copy
Range(Columns(cLastRow + 1, cLastcol - 5))


--

Dave Peterson

willwonka

Copy / Paste Easy
 
I'm not sure I see how the copies it out to Column CA?

Dave Peterson wrote:
cLastcol = Sheets("Initial by Laser").UsedRange.Columns.Count
cLastRow = Columns("A:A").Find(What:="Grand Total", LookAt:=xlWhole).Row

with worksheets("initial by Laser")
.range(.cells(cLastrow+1,"D"),.cells(clastrow+17," D")).copy _
destination:=.cells(clastrow+1,"E")
end with

Excel will resize the destination range to match the size of the copied range.

All this is happening on the "initial by laser" worksheet, right?


willwonka wrote:

I am trying to do a simple Copy/Paste

cLastcol = Sheets("Initial by Laser").UsedRange.Columns.Count
cLastRow = Columns("A:A").Find(What:="Grand Total",
LookAt:=xlWhole).Row

I want to copy "D" &clastrow+1: "D"&clastrow+17 to E+clastrow+1:
clastcol-5&clastrow+1
(In other words... D172:D192 to e172:ca192)

My sad attempt at code below:

Range("D" & cLastRow + 1 & ":" & "D" & cLastRow + 17).Copy
Range(Columns(cLastRow + 1, cLastcol - 5))


--

Dave Peterson



Dave Peterson

Copy / Paste Easy
 
I misunderstood.

How about:

With Worksheets("initial by Laser")
.Range(.Cells(clastrow + 1, "D"), .Cells(clastrow + 17, "D")).Copy _
Destination:=.Range(.Cells(clastrow + 1, "E"), .Cells(clastrow + 17, "Ca"))
End With



willwonka wrote:

I'm not sure I see how the copies it out to Column CA?

Dave Peterson wrote:
cLastcol = Sheets("Initial by Laser").UsedRange.Columns.Count
cLastRow = Columns("A:A").Find(What:="Grand Total", LookAt:=xlWhole).Row

with worksheets("initial by Laser")
.range(.cells(cLastrow+1,"D"),.cells(clastrow+17," D")).copy _
destination:=.cells(clastrow+1,"E")
end with

Excel will resize the destination range to match the size of the copied range.

All this is happening on the "initial by laser" worksheet, right?


willwonka wrote:

I am trying to do a simple Copy/Paste

cLastcol = Sheets("Initial by Laser").UsedRange.Columns.Count
cLastRow = Columns("A:A").Find(What:="Grand Total",
LookAt:=xlWhole).Row

I want to copy "D" &clastrow+1: "D"&clastrow+17 to E+clastrow+1:
clastcol-5&clastrow+1
(In other words... D172:D192 to e172:ca192)

My sad attempt at code below:

Range("D" & cLastRow + 1 & ":" & "D" & cLastRow + 17).Copy
Range(Columns(cLastRow + 1, cLastcol - 5))


--

Dave Peterson


--

Dave Peterson

willwonka

Copy / Paste Easy
 
Worked great .. thanks.
I did replcace "Ca" with cLastCol for it to be more dynamic..
Thanks again.


Dave Peterson wrote:
I misunderstood.

How about:

With Worksheets("initial by Laser")
.Range(.Cells(clastrow + 1, "D"), .Cells(clastrow + 17, "D")).Copy _
Destination:=.Range(.Cells(clastrow + 1, "E"), .Cells(clastrow + 17, "Ca"))
End With



willwonka wrote:

I'm not sure I see how the copies it out to Column CA?

Dave Peterson wrote:
cLastcol = Sheets("Initial by Laser").UsedRange.Columns.Count
cLastRow = Columns("A:A").Find(What:="Grand Total", LookAt:=xlWhole).Row

with worksheets("initial by Laser")
.range(.cells(cLastrow+1,"D"),.cells(clastrow+17," D")).copy _
destination:=.cells(clastrow+1,"E")
end with

Excel will resize the destination range to match the size of the copied range.

All this is happening on the "initial by laser" worksheet, right?


willwonka wrote:

I am trying to do a simple Copy/Paste

cLastcol = Sheets("Initial by Laser").UsedRange.Columns.Count
cLastRow = Columns("A:A").Find(What:="Grand Total",
LookAt:=xlWhole).Row

I want to copy "D" &clastrow+1: "D"&clastrow+17 to E+clastrow+1:
clastcol-5&clastrow+1
(In other words... D172:D192 to e172:ca192)

My sad attempt at code below:

Range("D" & cLastRow + 1 & ":" & "D" & cLastRow + 17).Copy
Range(Columns(cLastRow + 1, cLastcol - 5))

--

Dave Peterson


--

Dave Peterson




All times are GMT +1. The time now is 03:02 AM.

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