Hi friends,

I am using XL2003.

I am having trouble using a named range in a macro, even after refering the 
Help.
The named range lives in the active workbook.
My code is this:

Private Sub Worksheet_Activate()
    With [CompNames]
        Set c = .Find(Range("A1"))
        If Not c Is Nothing Then A = Sheets("Names").Cells(c.Row, 3)
    End With
    If ActiveSheet.Name <> A Then ActiveSheet.Name = A
End Sub

You will see that I have had to resort to using [ ] around the named range, 
which is the only way I could get the code to run.
I tried With Range("CompNames") which is what the Help seemed to indicate, and 
tried including the sheet name and the workbook name, but none of those worked.

I have checked the spelling of the named range, even copied and pasted it 
straight from the name box.

When I use With Range("CompNames") it returns the following error:

 

Runtime error '1004':
Method 'Range' of object '_Worksheet' failed


Anyone had a problem with this before?

Regards - Dave.
                                          
_________________________________________________________________
Use Messenger in your Hotmail inbox Find out how
http://windowslive.ninemsn.com.au/hotmail/article/823454/web-im-for-hotmail-is-here

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at 
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 

To post to this group, send email to excel-macros@googlegroups.com
If you find any spam message in the group, please send an email to:
Ayush Jain  @ jainayus...@gmail.com or
Ashish Jain @ 26may.1...@gmail.com
<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 6,500 subscribers worldwide and receive many nice notes about the 
learning and support from the group. Our goal is to have 10,000 subscribers by 
the end of 2009. Let friends and co-workers know they can subscribe to group at 
http://groups.google.com/group/excel-macros/subscribe

Reply via email to