98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel Training and help » Macro Errors
Macro Errors
Resolved · High Priority · Version 2003
Graham has attended:
Excel Intermediate course
Excel Advanced course
Macro Errors
I have recorded a macro which pastes data into a preselected row. Before running this macro the user has to have copied data from a seperate sheet. When the macro is run with data in the clipboard, it works correctly and pastes the data. If there is no data in the clipboard the macro returns the normal "Microsoft Visual Basic" error box showing Run-time error '1004': and the button choices of "End" and "Run". Is there a simple way of adding a personalised Error, e.g. ERROR: No data in Clipboard
Many thanks
Graham Warren
0777 5757 389
RE: Macro Errors
Hi Graham
Thank you for your question. You need to create an error handler
Go to your macro code. Immediately below the first line which will say SUB and then the Macro's name, type
On Error, go to errorhandler
Then on the line immediately above the final line, end sub type the following
exit sub
ErrorHandler:
If err.number = 1004 then
msgbox "There is No data in the clipboard"
else
msxbox "Unexpected Error "& err.number
end if
This will solve this problem for you
Regards
Stephen
Training information:
See also:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |