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: 275
Default Copy/paste error help

Hi,
I have this code that makes a search, then copies data from a particular
row, tehn pastes it into another workbook.

Sub print_mon_jobcard()
Dim i As String
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFirst As Range
Dim rngDestination As Range
Dim rngAllRecords As Range
Dim wks1 As Worksheet, wks2 As Worksheet

'On Error GoTo err_handler
i = InputBox("Please enter the job number you wish to print a job card for")
Set wks1 = ThisWorkbook.Worksheets("adhoc database")
Set wks2 = ThisWorkbook.Worksheets("Todays Calls")

On Error Resume Next
Set rngToSearch = wks1.Columns("b")
Set rngDestination = wks2.Cells(Rows.Count, "b").End(xlUp).Offset(1, 0)

Set rngFound = rngToSearch.Find _
(What:=i, _
LookIn:=xlValues, _
LookAt:=xlWhole)
If rngFound Is Nothing Then
MsgBox "No job with the number " & i & _
" has been found, please try again! "
Else
On Error GoTo err_handler
Set rngFirst = rngFound
Set rngAllRecords = rngFound
Do
Set rngAllRecords = Union(rngAllRecords, rngFound)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = rngFirst.Address
rngAllRecords.EntireRow.Copy rngDestination
wks3.PrintOut
End If
Exit Sub

err_handler:
MsgBox Error, , "Err " & Err.Number
End Sub


However each time I run the code it will not paste the collected data and
comes back with this response:-

err 1004

The information cannot be pasted because the copy and the paste are are not
the same size & shape. Try one of the following

*Click a single cell, then paste
*Select a rectangle thats the same size and shape then paste.


I have made an exact copy of the worksheet where the data is collected from
to paste it into but still get this error.

Any help........??
many thanks

 
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 error jenny Excel Discussion (Misc queries) 2 January 16th 09 01:53 PM
Copy/Paste error Anthony Excel Worksheet Functions 2 February 7th 07 06:46 PM
copy and paste error John Excel Programming 5 August 29th 05 02:55 PM
copy-paste error Bernie Deitrick Excel Programming 0 April 27th 04 05:12 PM
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) Tim[_36_] Excel Programming 4 April 23rd 04 02:53 AM


All times are GMT +1. The time now is 08:06 AM.

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"