PDA

View Full Version : Solved: paste from multi sheets to 1



Meatball
03-10-2009, 02:14 PM
I have several sheets in a workbook from which I want to copy from row 5 to last used (varies each sheet)and paste to a single sheet, then sort and subtotal the combined sheet. I can not get this macro (a combo of a couple already being used) to pull off the copy/paste part for me. It seemss to be having trouble with my paste range which I have tried to rewrite several different ways with no luck. Any help is appreciatted. It may a couple of days before I can return to check replies. Thanks in advance for any help
Dim i As Integer
For i = 3 To Sheets.Count
With Sheets(i)
Range("A5:I" & Range("B2000").End(xlUp).Row).Copy
Sheets("Combined Projects").Select
Range("A" & Rows.Count).End(xlUp).Offset (1)
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End With
Next
End Sub

mdmackillop
03-10-2009, 02:17 PM
Within a With statement, you need to Dot on (qualify) your ranges


Dim i As Integer
For i = 3 To Sheets.Count
With Sheets(i)
.Range("A5:I" & .Range("B2000").End(xlUp).Row).Copy
Sheets("Combined Projects").Select
Range("A" & Rows.Count).End(xlUp).Offset (1)
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End With
Next
End Sub

mdmackillop
03-10-2009, 02:21 PM
You can also simplify a little

For i = 3 To Sheets.Count
With Sheets(i)
.Range("A5:I" & .Range("B2000").End(xlUp).Row).Copy
Sheets("Combined Projects").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
End With
Next

Meatball
03-11-2009, 01:24 PM
mdm, took a minute but got it working. Thank you very much.
I have a book on VBA but I will be using this site "a lot" until I can get to where I understand what the book is telling me. Thanks again