View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel[_598_] joel[_598_] is offline
external usenet poster
 
Posts: 1
Default Handling different Error 1004 errors


You are trying to access an object that doesn't exist. for example if
you are looking for sheet 1 and your workbook doesn't have a sheet 1

with sheets("Sheet1")


Usually you either havve a typo error or you are looking in the wrong
workbook if you have multiple workbooks. Again you could have the same
error occuring on a Range object and you have the wrong worksheet open.
If you are using merged cells you can only get the upper left cell of
the merge group. So if your code tries to get any of the other merged
cells you could get this error.

I alway avoid using the select cell method becauwse this is prone to
this type error. To debug this error I often add all the variable to a
watch window then check the the following objects

1) Name - Use this for workbook and sheets to make sure you are on
the correct sheet
2) Range objects - Check Row and column
3) Parent.Name - Use this on worksheets to make surre you are in
the correct workbook

If you are using a selection. The set an object to the select property
and then add the watch to the new variable and then treat the selection
like a range object.

set MySelection = selection


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=173406

Microsoft Office Help