PDA

View Full Version : Solved: With End With Copy PasteSpecial Help



YellowLabPro
04-22-2007, 11:56 AM
I am attempting to copy a range of data from 1 worksheet to another using PasteSpecial.
Wss is Worksheet source
Ash is Activesheet target

1st error is on line: Type mismatch
With Sheets(Wss)


Ash.Range("A4", Ash.Cells(LastRow, "H")).ClearContents
With Sheets(Wss)
.Range("L2:S2" & LRow).Copy
End With
With Sheets(Ash)
.Range("A4").PasteSpecial
End With
I thought I had this qualified correclty, w/ the heirarchy of Range coming in below Worksheet object....

YellowLabPro
04-22-2007, 12:13 PM
I have the With, worked out: but it is only copying row 1, not the range to the bottom for some reason... there are 12,000 rows of data....


LastRow = Ash.Cells(Rows.Count, 1).End(xlUp).Row
LRow = Wss.Cells(Rows.Count, "L").End(xlUp).Row

With Wss
.Range("L2:S2" & LRow).Copy
End With
With Ash
.Range("A4").PasteSpecial
End With

Aussiebear
04-22-2007, 12:20 PM
Just guessig here Doug, but why not try the .End(xlUp).Row after "copy" and leave out LRow, and see what happens?

Someone with some knowlege will be along soon

YellowLabPro
04-22-2007, 12:27 PM
Ted,
Big no no there.
That copies the whole row over onto the target sheet..... good thing I save after each successful change or I would be in tears right now... :-)

Something is not just right here, I will keep searching, but thanks for the try

YellowLabPro
04-22-2007, 12:41 PM
The original code is below, but I am trying to either re-work it slightly or understand it better.
This code does copy and paste the entire range, I am trying to understand why my version only copies and pastes the first row in the range?
I have switched up the hardcoded sheet names w/ variables.
DataEdited= Wss
PCCombined_FF= Ash

With Sheets("DataEdited").Range("L2:S2")
Sheets("DataEdited").Range(.Cells, .Cells.End(xlDown)).Copy
End With
With Sheets("PCCombined_FF")
.Range("A4").PasteSpecial
End With

YellowLabPro
04-22-2007, 12:48 PM
I found my error:
The range was off:
L2:S2

Should have been:
L2:S