Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help on range and Name object in excel

Status
Not open for further replies.

pdp2907

Programmer
Jan 20, 2001
2
US
Hi
I Named a cell range in Excel sheet using the Name command as follows:
Code:
Names.Add Name:="Augdelta120", RefersTo:="Sheet1!$B$6:$M$6"
Names.Add Name:="julydelta500", RefersTo:="=Sheet18!$B$5:$M$5"

For i = 1 To Augdelta120.Columns.Count

Augdelta120.Offset(10, 10) = ((julydelta500.Cells(j, k).Value) - (Augdelta120.Cells(j, k).Value)) / (julydelta500.Cells(j, k).Value)

Next i
Now when I try to use the named ranges to do some calculations Excel throws up error

error 1004

method 'range' of Object'global' failed

is there some thing else that I need to do.

please help

thanx

pdp2907

 
Each or your range names need to be in brackets
need an = in the first name assignment
Code:
    Names.Add Name:="Augdelta120", RefersTo:="=Sheet1!$B$6:$M$6"
j 0& k are unasigned

Code:
    Names.Add Name:="Augdelta120", RefersTo:="=Sheet1!$B$6:$M$6"
    Names.Add Name:="julydelta500", RefersTo:="=Sheet2!$B$5:$M$5"
    
    For i = 1 To [Augdelta120].Columns.Count
        
        [Augdelta120](10, 10).Value = (([julydelta500](j, k).Value) - ([Augdelta120](j, k).Value)) / ([julydelta500](j, k).Value)
        
    Next i
the corrections that I could make BUT.

[Augdelta120](10, 10).Value does not make sense.

Skip,
Skip@TheOfficeExperts.com
 
Hi SkipVought

thanx for your promt reply. I really appreciate it. but excel still throws an error.
The answer to your questions are :
Code:
i = 1 to [Augdelta120].Columns.Count

j =1 ( which  I had not defined earlier )

[Augdelta120](j, k).Value = (([julydelta500](j, k).Value) - ([Augdelta120](j, k).Value))


excel highlights [Augdelta120](j,k).Value in the for loop and throws up a compile error with the message 'wrong number of arguements or invalid property assignment'

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top