LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy and Paste select data to another workbook.


I would like to copy data from a worksheet; F14, F16, F19 and copy the
to another workbook where they would be pasted in a select order on on
line.

I have the following macro written, thanks to Ron de Bruin, but I kno
I am missing something in order to have the data pasted. I can get th
workbook to open, but then I get a Run-Time error '1004' pastespecia
method of range class failed. I am not sure what the code should be t
paste the selected data.

Sub SendToTracking()
Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function
Function bIsBookOpen(ByRef szBookName As String) As Boolean
On Error Resume Next
bIsBookOpen = Not (Application.Workbooks(szBookName) Is Nothing)
End Function

Function Lastcol(sh As Worksheet)
On Error Resume Next
Lastcol = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Column
On Error GoTo 0
End Function

Sub copy_to_another_workbook()
Dim smallrng As Range
Dim destrange As Range
Dim destWB As Workbook
Dim Lr As Long

Application.ScreenUpdating = False
If bIsBookOpen("P&WM Estimate Tracking Sheet.xls") Then
Set destWB = Workbooks("P&WM Estimate Tracking Sheet.xls")
Else
Set destWB = Workbooks.Open("N:\Estimate Sheet\P&WM Estimate Trackin
Sheet.xls")
End If
Lr = LastRow(destWB.Worksheets("Tracking Sheet")) + 1
For Each smallrng In ThisWorkbook.Worksheets("Inpu
Form").Range("F14,F16,F19").Areas
Set destrange = destWB.Worksheets("Tracking Sheet").Range("A" & Lr)
smallrng.Copy destrange
Next smallrng
destrange.PasteSpecial xlPasteValues, , False, False
Application.CutCopyMode = False
destWB.Close True
Application.ScreenUpdating = True
End Sub

Any help would be greatly appreciated.

Thank Yo

--
tanyhar
-----------------------------------------------------------------------
tanyhart's Profile: http://www.excelforum.com/member.php...fo&userid=3514
View this thread: http://www.excelforum.com/showthread.php?threadid=55100

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy and paste data from one sheet to another in a single workbook SITCFanTN Excel Programming 0 June 10th 06 01:58 PM
Selecting data from 1 workbook to copy and paste to a 2nd workbook JackSpam Excel Programming 2 July 20th 05 02:33 AM
copy data from one worksheet and paste into another workbook Mike R. Excel Programming 1 December 21st 04 07:35 AM
Copy worksheet and paste it in New workbook, all data except Formulas Sudarshan Excel Programming 4 May 26th 04 06:51 PM
Select All and copy and paste Ashok[_2_] Excel Programming 7 November 11th 03 03:46 AM


All times are GMT +1. The time now is 11:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"