PC Review


Reply
Thread Tools Rate Thread

Copy & Paste to Last Empty Row

 
 
=?Utf-8?B?QUxBVEw=?=
Guest
Posts: n/a
 
      11th Sep 2007
I am trying to copy data from DestSheet to the last empty row in
PivotTableData worksheet. I have the following code which does everything
correctly until the last line. The "LastRowTemp" variable has the correct
value, however, the copy never happens. I get an error that says.... "Run
time error 424: Object Required".

I've checked & my variables are all named correctly. Any ideas?

Thanks!

Dim DestSheet As Worksheet
Dim PivotTableData As Worksheet
Dim LastRowTemp As Long

Set DestSheet = Sheets("Sheet3")
Set PivotTableData = Worksheets("Sheet4")

PivotTableData.Activate
LastRowTemp = Cells(Rows.Count, 1).End(xlUp)(2).Row !Get last empty row
'Copy columns User Name from Sheet 1 to Sheet 2
With DestSheet
.Range(.Range("A2"), .Range("F2").End(xlDown)).Copy
End With
PivotTableData.["A" & LastRowTemp].End(xlUp)(1).PasteSpecial Paste:=xlValues
 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      11th Sep 2007
try this...

PivotTableData.Cells(LastRowTemp, "A").PasteSpecial Paste:=xlValues
--
HTH...

Jim Thomlinson


"ALATL" wrote:

> I am trying to copy data from DestSheet to the last empty row in
> PivotTableData worksheet. I have the following code which does everything
> correctly until the last line. The "LastRowTemp" variable has the correct
> value, however, the copy never happens. I get an error that says.... "Run
> time error 424: Object Required".
>
> I've checked & my variables are all named correctly. Any ideas?
>
> Thanks!
>
> Dim DestSheet As Worksheet
> Dim PivotTableData As Worksheet
> Dim LastRowTemp As Long
>
> Set DestSheet = Sheets("Sheet3")
> Set PivotTableData = Worksheets("Sheet4")
>
> PivotTableData.Activate
> LastRowTemp = Cells(Rows.Count, 1).End(xlUp)(2).Row !Get last empty row
> 'Copy columns User Name from Sheet 1 to Sheet 2
> With DestSheet
> .Range(.Range("A2"), .Range("F2").End(xlDown)).Copy
> End With
> PivotTableData.["A" & LastRowTemp].End(xlUp)(1).PasteSpecial Paste:=xlValues

 
Reply With Quote
 
=?Utf-8?B?TWljaGFlbA==?=
Guest
Posts: n/a
 
      11th Sep 2007
Try this:
PivotTableData.Range("A" & LastRowTemp).End(xlUp)(1).PasteSpecial
Paste:=xlValues

--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"ALATL" wrote:

> I am trying to copy data from DestSheet to the last empty row in
> PivotTableData worksheet. I have the following code which does everything
> correctly until the last line. The "LastRowTemp" variable has the correct
> value, however, the copy never happens. I get an error that says.... "Run
> time error 424: Object Required".
>
> I've checked & my variables are all named correctly. Any ideas?
>
> Thanks!
>
> Dim DestSheet As Worksheet
> Dim PivotTableData As Worksheet
> Dim LastRowTemp As Long
>
> Set DestSheet = Sheets("Sheet3")
> Set PivotTableData = Worksheets("Sheet4")
>
> PivotTableData.Activate
> LastRowTemp = Cells(Rows.Count, 1).End(xlUp)(2).Row !Get last empty row
> 'Copy columns User Name from Sheet 1 to Sheet 2
> With DestSheet
> .Range(.Range("A2"), .Range("F2").End(xlDown)).Copy
> End With
> PivotTableData.["A" & LastRowTemp].End(xlUp)(1).PasteSpecial Paste:=xlValues

 
Reply With Quote
 
=?Utf-8?B?TWljaGFlbA==?=
Guest
Posts: n/a
 
      11th Sep 2007
Try this:
Set DestSheet = Sheets("Sheet3")
Set PivotTableData = Worksheets("Sheet4")
LastRowDest = Range("F65536").End(xlUp).Row

PivotTableData.Activate
LastRowTemp = Cells(Rows.Count, 1).End(xlUp).Row
'Copy columns User Name from Sheet 1 to Sheet 2
With DestSheet
.Range(.Range("A2"), .Range("F2:F" & LastRowDest)).Copy
Destination:=PivotTableData.Range("A" & LastRowTemp)
End With

--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"ALATL" wrote:

> I am trying to copy data from DestSheet to the last empty row in
> PivotTableData worksheet. I have the following code which does everything
> correctly until the last line. The "LastRowTemp" variable has the correct
> value, however, the copy never happens. I get an error that says.... "Run
> time error 424: Object Required".
>
> I've checked & my variables are all named correctly. Any ideas?
>
> Thanks!
>
> Dim DestSheet As Worksheet
> Dim PivotTableData As Worksheet
> Dim LastRowTemp As Long
>
> Set DestSheet = Sheets("Sheet3")
> Set PivotTableData = Worksheets("Sheet4")
>
> PivotTableData.Activate
> LastRowTemp = Cells(Rows.Count, 1).End(xlUp)(2).Row !Get last empty row
> 'Copy columns User Name from Sheet 1 to Sheet 2
> With DestSheet
> .Range(.Range("A2"), .Range("F2").End(xlDown)).Copy
> End With
> PivotTableData.["A" & LastRowTemp].End(xlUp)(1).PasteSpecial Paste:=xlValues

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA - Copy/Paste to next empty cell megangomez Microsoft Excel Programming 1 22nd Nov 2009 05:18 PM
empty cell / copy and paste Helmut Microsoft Excel Programming 7 26th May 2009 01:11 PM
Copy, paste first empty row =?Utf-8?B?VG9iaWU=?= Microsoft Excel Programming 1 13th Nov 2006 03:44 PM
Copy and Paste in the first empty available line. =?Utf-8?B?RXRpZW5uZQ==?= Microsoft Excel Programming 5 3rd Aug 2006 03:49 PM
copy paste from net to office...empty box =?Utf-8?B?bmFtbmlr?= Microsoft Word New Users 2 27th Mar 2004 02:41 AM


Features
 

Advertising
 

Newsgroups
 


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