ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   save a range to copy for later (https://www.excelbanter.com/excel-programming/434681-save-range-copy-later.html)

John

save a range to copy for later
 
I want to select a range starting with active cell to the last row and copy
it... but first I have to clear the copy range starting in A3... then paste
in A3. can someone help?

first = ActiveCell.Address
col = ActiveCell.Column
lastrow = ActiveSheet.Cells(Rows.Count, col).End(xlUp).Row
lst = "r" & lastrow & "c" & col

Range("A3").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents


Range(first, lst).Copy
Range("a3").Select
Selection.PasteSpecial Paste:=xlValue

Dave Peterson

save a range to copy for later
 
And the activecell won't be in column A, right???

dim TopCell as range
dim BotCell as range

with activesheet
if activecell.column = 1 then
msgbox "Not from column A!"
else
set topcell = activecell
set botcell = .cells(.rows.count,topcell.column).end(xlup)

if topcell.row botcell.row then
msgbox "this doesn't look right!"
else
.range("a3:a" & .rows.count).clearcontents
.range(topcell, botcell).copy
.range("A3").pastespecial paste:=xlpastevalues
end if
end if
end with


John wrote:

I want to select a range starting with active cell to the last row and copy
it... but first I have to clear the copy range starting in A3... then paste
in A3. can someone help?

first = ActiveCell.Address
col = ActiveCell.Column
lastrow = ActiveSheet.Cells(Rows.Count, col).End(xlUp).Row
lst = "r" & lastrow & "c" & col

Range("A3").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents


Range(first, lst).Copy
Range("a3").Select
Selection.PasteSpecial Paste:=xlValue


--

Dave Peterson

John

save a range to copy for later
 
Nevermind...
lastcell = ActiveSheet.Cells(Rows.Count, col).End(xlUp).Address

rather than .row

"John" wrote:

I want to select a range starting with active cell to the last row and copy
it... but first I have to clear the copy range starting in A3... then paste
in A3. can someone help?

first = ActiveCell.Address
col = ActiveCell.Column
lastrow = ActiveSheet.Cells(Rows.Count, col).End(xlUp).Row
lst = "r" & lastrow & "c" & col

Range("A3").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents


Range(first, lst).Copy
Range("a3").Select
Selection.PasteSpecial Paste:=xlValue



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

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