Copy and pasting issue

nzkiwi

New Member
Joined
Nov 27, 2012
Messages
24
Hi there,

OK here's the deal, I have two documents; 1 called payroll the other called rosters. I have used this forum to weed-out all but one bug in the code. this is at the point where the selected cells are pasted.

It doesnt matter if i change both of the cells.select to a range("a1:az65536").select it still errors at the Selection.Paste when the code is run.

If I take out the paste the code runs perfect. but i do need it to paste.

Cheers in advance.



Code:
Public Sub Data_Import()
Set WB = ActiveWorkbook
Set WB1 = Workbooks.Open(Application.GetOpenFilename)

   
MenuForm.Hide

   
Application.ScreenUpdating = False
Waiting.Show vbModeless
Waiting.Repaint


'open roster to import into payroll
        WB1.Activate
        Sheets("Master_Dump").Select
        Cells.Select
        Selection.Copy

'paste roster in to payroll document
        WB.Activate
        With Sheets("roster information").Select
            Sheets("roster information").Unprotect Password:=Sheets("menu").Range("az27")
                Cells.Select
                Selection.Paste
              
            Sheets("roster information").Protect Password:=Sheets("menu").Range("az27")
        End With
'close the rostering document
WB1.Close

'back to main menu
Waiting.Hide
Sheets("blank").Select
MenuForm.Show
Application.ScreenUpdating = True
Waiting.Hide


End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Give this a try.
Change from:

Cells.Select
Selection.Paste

To:
Sheets("roster information").Range("A1").Paste
 
Upvote 0
Try
WB1.Sheets("Master_Dump").UsedRange.Copy WB.Sheets("roster information").Range("A1")
after unprotecting the sheet of course.
 
Upvote 0

Forum statistics

Threads
1,215,862
Messages
6,127,386
Members
449,382
Latest member
DonnaRisso

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top