Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / August 2007

Tip: Looking for answers? Try searching our database.

Copy a R1C1 formula to a user defined range results #NAME? error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mzehr - 20 Aug 2007 20:26 GMT
I have a worksheet in which a user will select a defined range somewhere in
column A, in which I want to put the following relative formula, (assuming
that the user is starting in cell A12):
=INDEX(Chart!$A:$A,MATCH($C12,Chart!$C:$C,0))
This formula would be copied down (or inserted in) to each cell in column A
within the user defined range.

I have a short subroutine with the following code:

Sub GL_Lookup()
Dim i As Variant
i = ActiveCell
For Each i In Selection
If i.Offset(0, 1).Value = "DR" Then
   i.FormulaR1C1 = "=INDEX(Chart!A:A,MATCH(RC[2],Chart!C[2]:C[2],0))"
ElseIf i.Offset(0, 1).Value = "CR" Then
   i.FormulaR1C1 = "=INDEX(Chart!A:A,MATCH(RC[2],Chart!C[2]:C[2],0))"
End If

Next
End Sub

The routine works well, and the formula looks correct in the individual
cells within the range, however each cell contains the error message #NAME?
I have to go into each cell, hit F2, then Enter, and the correct result show
up.
I must be missing something really simple in this and appreciate any help
someone can offer.

Thanks,
Mike
JE McGimpsey - 20 Aug 2007 20:41 GMT
One way:

   Dim rCell As Range
   For Each rCell In Selection
   If rCell.Offset(0, 1).Value = "DR" Then
       rCell.FormulaR1C1 = "=INDEX(Chart!C1,MATCH(RC[2],Chart!C[2],0))"
   ElseIf rCell.Offset(0, 1).Value = "CR" Then
       rCell.FormulaR1C1 = "=INDEX(Chart!C1,MATCH(RC[2],Chart!C[2],0))"
   End If

> I have a worksheet in which a user will select a defined range somewhere in
> column A, in which I want to put the following relative formula, (assuming
[quoted text clipped - 27 lines]
> Thanks,
> Mike
mzehr - 20 Aug 2007 20:50 GMT
Fantastic!  Thanks

> One way:
>
[quoted text clipped - 37 lines]
> > Thanks,
> > Mike
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.