You are here:

Excel/Copying and pasting between sheets


Hi Tom,

Yesterday you wrote this code for me and it works, except that it only copies the "A" entry in the last used row

sub abc()
Dim r as Range
set r = cells(rows.count,"A").End(xlup)
r.copy Range("F2")

End Sub

I tried changing that to be "B:R", but that does not work.

Also the range("F2") part does not want to work at all, I only have office 2003, maybe that is affecting it, but when I tried to use the following it pasted the information in the one A-entry into every cell in the destination. and not the entire rows worth into each destination cell.

shDest.Range("B1:B17").PasteSpecial Paste:=xlPasteValues, Transpose:=True

So to clarify I want the info in the last row starting in column B ( 17 cells worth) to be copied and pasted to the column B1:B17 in the next sheet.
Application.CutCopyMode = False


So this finds the last row in column B of Sheet1 (change as appropriate in each case) and copies the data from columns B to R for that row and pastes that data as transposed values to cells B1:B17 on Sheet2.  

sub abc()
Dim r as Range
Dim shSrc as Worksheet, shDest as Worksheet
set shSrc = Worksheets("Sheet1")
set shDest = Worksheets("Sheet2")
set r = shSrc.cells(shSrc.rows.count,"B").End(xlup).Resize(1,17)
shDest.Range("B1:B17").PasteSpecial Paste:=xlPasteValues, Transpose:=True
End Sub

Tested and worked for me as I expected.

Tom Ogilvy

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Tom Ogilvy


Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]


Extensive experience.

Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2017 All rights reserved.