Application.Goto Reference gets error 1004

C

cellist

I get "Run-time error 1004, Reference is not valid" when I execute
Application.Goto Reference:="AccountAbbreviations"
Selection.ClearContents
The name "AccountAbbreviations" is, in fact, not defined. How can I check
for not defined so that the code can continue?

TIA,

Phil
 
J

JE McGimpsey

One way:

Dim rTest As Range
On Error Resume Next
Set rTest = ActiveWorkbook.Names( _
"AccountAbbreviations").RefersToRange
On Error GoTo 0
If Not rTest Is Nothing Then rTest.ClearContents
 
C

Chip Pearson

Try

Application.Goto Range("AccountAbbreviations"),True

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
P

PhilRichcreek

One way:

    Dim rTest As Range
    On Error Resume Next
    Set rTest = ActiveWorkbook.Names( _
            "AccountAbbreviations").RefersToRange
    On Error GoTo 0
    IfNotrTest Is Nothing Then rTest.ClearContents

   In article <[email protected]>,





- Show quoted text -

thanks JE
 
P

PhilRichcreek

Try

Application.Goto Range("AccountAbbreviations"),True

Cordially,
Chip Pearson
Microsoft MVP
   ExcelProduct Group
Pearson Software Consulting, LLCwww.cpearson.com
(email on web site)



- Show quoted text -

thanks Chip.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top