PC Review


Reply
Thread Tools Rate Thread

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

 
 
=?Utf-8?B?bXplaHI=?=
Guest
Posts: n/a
 
      20th Aug 2007
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
 
Reply With Quote
 
 
 
 
JE McGimpsey
Guest
Posts: n/a
 
      20th Aug 2007
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


In article <59A70D1F-2A56-4BEC-BC9A-(E-Mail Removed)>,
mzehr <(E-Mail Removed)> wrote:

> 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

 
Reply With Quote
 
=?Utf-8?B?bXplaHI=?=
Guest
Posts: n/a
 
      20th Aug 2007
Fantastic! Thanks

"JE McGimpsey" wrote:

> 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
>
>
> In article <59A70D1F-2A56-4BEC-BC9A-(E-Mail Removed)>,
> mzehr <(E-Mail Removed)> wrote:
>
> > 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

>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
User Defined formula, selecting range p.strijbosch@chello.nl Microsoft Excel Programming 3 5th Jan 2006 09:27 AM
Re: User defined formula - concatenate range Ian Microsoft Excel Discussion 0 15th Sep 2005 05:06 PM
Re: external range in VBA (user defined formula) Gord D Microsoft Excel Programming 0 23rd Jul 2003 06:25 PM
Re: external range in VBA (user defined formula) BrianB Microsoft Excel Programming 0 22nd Jul 2003 08:26 AM
Re: external range in VBA (user defined formula) Tim Zych Microsoft Excel Programming 0 22nd Jul 2003 02:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:18 AM.