![]() |
PasteSpecial error handling
I am currently in the middle of developing a macro which as part of the
routine will use something like Range("A1").PasteSpecial to paste whatever is currently on the clipboard. However, there is not necessarily anything waiting to be pasted and, if this was the case, the above statement would generate a runtime error. Can anyone suggest a way to 1) Detect whether or not there is data on the clipboard, and skip the routine if so or 2) If the macro tries to paste something that's not there, it handles the error and continues to function. Thanks in advance. |
PasteSpecial error handling
You could check the status of the paste button on the Edit Commandbar.
You could just do On Error Resume Next Range("A1").Pastespecial On Error goto 0 this will suppress the error if it occurs. -- Regards, Tom Ogilvy "JakeyC" wrote in message oups.com... I am currently in the middle of developing a macro which as part of the routine will use something like Range("A1").PasteSpecial to paste whatever is currently on the clipboard. However, there is not necessarily anything waiting to be pasted and, if this was the case, the above statement would generate a runtime error. Can anyone suggest a way to 1) Detect whether or not there is data on the clipboard, and skip the routine if so or 2) If the macro tries to paste something that's not there, it handles the error and continues to function. Thanks in advance. |
PasteSpecial error handling
Jakey,
I would use something like: If Application.CutCopyMode Then Range("A1").PasteSpecial xlPasteValues Otherwise, you could end up pasting items from the clipboard that weren't placed there by Excel. HTH, Bernie MS Excel MVP "JakeyC" wrote in message oups.com... I am currently in the middle of developing a macro which as part of the routine will use something like Range("A1").PasteSpecial to paste whatever is currently on the clipboard. However, there is not necessarily anything waiting to be pasted and, if this was the case, the above statement would generate a runtime error. Can anyone suggest a way to 1) Detect whether or not there is data on the clipboard, and skip the routine if so or 2) If the macro tries to paste something that's not there, it handles the error and continues to function. Thanks in advance. |
PasteSpecial error handling
An even neater solution than I requested!
Thanks a lot to you both. |
All times are GMT +1. The time now is 02:13 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com