Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Runtime error 1004

Hi

When my macro tries to run the line below if the selected cell has no
formulas i get a runtime error 1004 - no cells were found. How to get around
this?

Selection.DirectPrecedents.Select

Kind regards
Igor

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Runtime error 1004

Sub noprecedents()
On Error GoTo nomo
Selection.DirectPrecedents.Select
nomo:
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"IgorM" wrote in message
...
Hi

When my macro tries to run the line below if the selected cell has no
formulas i get a runtime error 1004 - no cells were found. How to get
around this?

Selection.DirectPrecedents.Select

Kind regards
Igor


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Runtime error 1004

I would be inclined to do it this way...

dim rngPrecedents as range

on error resume next
set rngPrecedents = Selection.DirectPrecedents
on error goto 0

if rngPrecedents is nothing then
msgbox "sorry no precedents"
else
rngPrecedents.select
end if

It is a bit longer than Don's code (which works) but it does not leave you
in an error handler. My preference is to avoid errors were possible. If I
have to generate an error I try to dismiss it as soon as possible and resume
normal execution.
--
HTH...

Jim Thomlinson


"IgorM" wrote:

Hi

When my macro tries to run the line below if the selected cell has no
formulas i get a runtime error 1004 - no cells were found. How to get around
this?

Selection.DirectPrecedents.Select

Kind regards
Igor

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Runtime error 1004

I tried

Dim mrngPrecedents As Range
On Error Resume Next
Set mrngPrecedents = Selection.DirectPrecedents

But I still get the same error


Użytkownik "Jim Thomlinson"
napisał w wiadomo¶ci
...
I would be inclined to do it this way...

dim rngPrecedents as range

on error resume next
set rngPrecedents = Selection.DirectPrecedents
on error goto 0

if rngPrecedents is nothing then
msgbox "sorry no precedents"
else
rngPrecedents.select
end if

It is a bit longer than Don's code (which works) but it does not leave you
in an error handler. My preference is to avoid errors were possible. If I
have to generate an error I try to dismiss it as soon as possible and
resume
normal execution.
--
HTH...

Jim Thomlinson


"IgorM" wrote:

Hi

When my macro tries to run the line below if the selected cell has no
formulas i get a runtime error 1004 - no cells were found. How to get
around
this?

Selection.DirectPrecedents.Select

Kind regards
Igor



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
runtime error '1004' application or object defined error Janis Excel Programming 4 November 18th 09 03:01 PM
runtime error '1004' application or object defined error. Please help deej Excel Programming 0 August 1st 07 09:26 AM
Runtime Error 1004 Lizz45ie[_10_] Excel Programming 4 November 8th 05 10:51 PM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
What is RunTime Error '1004'? Ed Excel Programming 3 November 18th 04 07:09 PM


All times are GMT +1. The time now is 02:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"