ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code to halt a macro (https://www.excelbanter.com/excel-programming/296348-code-halt-macro.html)

Floss

Code to halt a macro
 
Hi, I made a 'paste macro' which pastes data from clipboard to a designated area in the worksheet. However if a user runs the macro while there is no data in the clipboard macro error occurs. Need help with the code (if(iserror)) so I can display a text message, noting the missing data in the clipboard, and then terminate the macro. After which, the user will hopefully copy the necessary data to clipboard and rerun the 'paste macro'

Thank you in advance for all of your help..

Floss

Tom Ogilvy

Code to halt a macro
 
if application.CutcopyMode = False then
msgbox "No range copied. Exiting . . . "
Exit Sub
End if

--
Regards,
Tom Ogilvy

"floss" wrote in message
...
Hi, I made a 'paste macro' which pastes data from clipboard to a

designated area in the worksheet. However if a user runs the macro while
there is no data in the clipboard macro error occurs. Need help with the
code (if(iserror)) so I can display a text message, noting the missing data
in the clipboard, and then terminate the macro. After which, the user will
hopefully copy the necessary data to clipboard and rerun the 'paste macro'.

Thank you in advance for all of your help...

Floss





All times are GMT +1. The time now is 11:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com