Showing posts with label excel. Show all posts
Showing posts with label excel. Show all posts

Thursday, December 17, 2009

Fix: Excel VBA “User-defined type not defined”: DataObject

Problem

An Excel VBA subroutine that involves interaction with the Windows Clipboard fails to run with the error: “Compile error: User-defined type not defined.”  The line of code highlighted by Excel as being the cause of the error includes a reference to the “DataObject” object type.

Solution

(Tested on my machine with Excel 2003 SP3)

In the Microsoft Visual Basic editor:

  • Stop debugging by clicking the “Stop” button on the toolbar (if debugging isn’t already stopped).
  • Tools menu | References
  • In the list of available references, find “Microsoft Forms 2.0 Object Library”, check it, and click OK.  (For me, this was the 2nd unchecked item from the top of the list; it wasn’t sorted alphabetically in the list like most of the rest of the listed items.)
  • Run the macro again.

That’s it!  Hope this helps!

Tuesday, August 05, 2008

Excel tip: Shift+F2 = Edit Cell Comment

A quick tip for Microsoft Excel that I've just found, and is currently making my life easier: Shift+F2 jumps to editing the cell comment (note / annotation) for the current cell.

This is a lot nicer than having to go over to the mouse and right-click on a cell, then choose "Edit Comment" (or "Insert Comment" in the case of a cell that doesn't have a comment yet) from the context menu when doing heavy editing work on an Excel sheet.

This works in Excel 2003; it might also work in other Excel versions as well.

Bonus tip: F2 alone (without holding Shift) edits the existing value in the current cell.  This is another time-saver that allows you to edit the value in a cell without having to move over to the mouse. 

The use of F2 to mean "edit the current value" is a semi-standard that works in many other Windows applications as well.  For example, F2 in Windows Explorer begins editing the name of the selected file or folder (to allow the file or folder to be renamed).