Code to halt a macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
if application.CutcopyMode = False then
msgbox "No range copied. Exiting . . . "
Exit Sub
End if

--
Regards,
Tom Ogilvy

floss said:
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'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top