VBA paste help

bolo

Active Member
Joined
Mar 23, 2002
Messages
423
Hi i was wondering if ne VBA experts can help.
I have a work sheet macro than run s off a command button to copy information from one sheet to another. the problem is the macro only works half the time. the activesheet.paste seems to generate a run time 1004 error. THe takeonfocus property of the buttons are false.
The worksheets are protected and hidden but before i paste the sheets are unhidden and unprotected. What is annoying is that it does work sometimes but not others. i don't undersatnd

Thanks for the help
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Yep heres the code
I am well aware of using the 'with' key word but the problems occured after i inserted this key word
If response = vbYes Then
Sheets(nam).Visible = xlSheetVisible

Sheets(nam).Range("A1:F12").Copy
Assumptions.Visible = xlSheetVisible
Assumptions.Unprotect
'Assumptions.Select
'Assumptions.Range("B3:G14").Select
ActiveSheet.Paste Destination:=Assumptions.Range("B3:G14")
Assumptions.Visible = xlSheetHidden
Assumptions.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
end if

x2

Update. This macro works every 4 trys. the first paste causes the error the first time. The second paste causes the error the second time i run it.
the third time the first paste line causes the problem and then it works. i don't get it.

thx for the quick reponse!
This message was edited by bolo on 2002-10-16 20:42
 
Upvote 0

Forum statistics

Threads
1,213,490
Messages
6,113,957
Members
448,535
Latest member
alrossman

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