macro errors
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel Training and help » Macro Errors

Macro Errors

resolvedResolved · High Priority · Version 2003

replyReply Fri 3 Oct 2008, 15:00Delegate Graham said...

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

For upcoming training course dates see: Pricing & availability

replyReply Mon 6 Oct 2008, 11:07 Edited on Mon 6 Oct 2008, 11:08Trainer Stephen said...

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

 

Please browse our web site to find out more about
excel 2003 training and other Microsoft training courses.

Excel tip:

Manually rotating a 3D chart

To manually rotate a 3D chart;
Select the chart (edit mode) and click on one corner of the chart display area. A selection border will appear, using the left mouse button on one of the chart's "corners" (mouse pointer changes to a cross) drag the image which becomes a line representation of the chart (as you begin to drag) and rotate the chart to a view of your choice.
If you dont get it right first time, dont worry, the manoeuver is a little bit tricky.

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard