On error and paste.special

richarddawson

Board Regular
Joined
Oct 18, 2014
Messages
95
I have a sub which starts with an On Error GoTo and then continues to use a PasteSpecial.
(I can paste code if required, but I suspect there may be an easy answer from someone here!)

Now if there is nothing to paste it does not go to the label but just stops at the PasteSpecial.

I suspect this is a system thing. I would welcome any comments.

I am using 64 bit 365.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Without seeing the code, we really cannot comment on it.
 
Upvote 0
I see what you mean!

Where WSped is a defined worksheet
Code:
Function pasteTicker()
    On Error GoTo ErrorA
    sleep 1000 
    pasteTicker = 0
    WSped.Range("a1:z500").ClearContents
    WSped.Activate
    WSped.Range("A1").Select
    ActiveSheet.PasteSpecial Format:="Text", Link:=False, DisplayAsIcon:=False
    sleep 200
    Exit Function
ErrorA:
    Debug.Print "nothing to paste  " & tickerName
    errorString = errorString + "pasteFail" & " "
    pasteTicker = 999
    Stop
End Function
 
Last edited by a moderator:
Upvote 0
How are you calling it? (it won't work as a worksheet function if that's what you're trying to do)
 
Upvote 0
Well it actually does - about 98% of the time.
The error I have is when the site I am getting data from is slow, and there is nothing to paste. (At least I think that is the problem).
I need to do this hundreds of thousands of time so do not want to give unnecessary time.
What I was aiming to do was, if an error was detected, give another copy to the site, and then increase the delay period.

Cheers Richard
 
Upvote 0
That shouldn't work at all if you call it from a cell. If it does, I'm slightly horrified.
 
Upvote 0
There's nothing wrong with the code, so I'd have to assume something else is interfering, such as event code.
 
Upvote 0
I have nothing odd in the programme, I have even restricted excel to only using 1 core (well, I did, haven't checked it recently - I will).
It works nicely most of the time.

Have you any suggestions, please?
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

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