PC Review


Reply
Thread Tools Rate Thread

Cells Within Range Failure?

 
 
Bob Zimski
Guest
Posts: n/a
 
      25th Nov 2008
I don't know why, but the compiler is protesting the second to last line and
I don't know why. What have I missed?

Thanks

For i = maxrows To 2 Step -1
FormulaStr =
"=IF(ISNA(VLOOKUP(cells(i,1),[NegsExceptions.xls]Sheet1!$A$1:$C$18,1,FALSE)),""x"",VLOOKUP(cells(i,1),[NegsExceptions.xls]Sheet1!$A$1:$C$18,1,FALSE))"
Range(Cells(i, 5)).Formula = FormulaStr
Next i

 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      25th Nov 2008
Bob,

There was also an error in your Vlookup because you had
cells(i,1) inside the quotes it was treated as text and you wanted a
variable. try this instead

For i = maxrows To 2 Step -1
FormulaStr = "=IF(ISNA(VLOOKUP(" & Cells(i, 1).Address &
",[NegsExceptions.xls]Sheet1!$A$1:$C$18,1,FALSE)),""x"",VLOOKUP(" & Cells(i,
1).Address & ",[NegsExceptions.xls]Sheet1!$A$1:$C$18,1,FALSE))"
Cells(i, 5).Formula = FormulaStr
Next i


Mike


"Bob Zimski" wrote:

> I don't know why, but the compiler is protesting the second to last line and
> I don't know why. What have I missed?
>
> Thanks
>
> For i = maxrows To 2 Step -1
> FormulaStr =
> "=IF(ISNA(VLOOKUP(cells(i,1),[NegsExceptions.xls]Sheet1!$A$1:$C$18,1,FALSE)),""x"",VLOOKUP(cells(i,1),[NegsExceptions.xls]Sheet1!$A$1:$C$18,1,FALSE))"
> Range(Cells(i, 5)).Formula = FormulaStr
> Next i
>

 
Reply With Quote
 
Jim Thomlinson
Guest
Posts: n/a
 
      25th Nov 2008
What you have will not produce a valid formula. In your string you have
cells(i,1)
which is not going to be evalueated to a value. It will be exactly what you
see.

"=IF(ISNA(VLOOKUP(" & cells(i,1) &
",[NegsExceptions.xls]Sheet1!$A$1:$C$18,1,FALSE)),""x"",VLOOKUP(" &
cells(i,1) & ",[NegsExceptions.xls]Sheet1!$A$1:$C$18,1,FALSE))"

Assuming all else to be correct
--
HTH...

Jim Thomlinson


"Bob Zimski" wrote:

> I don't know why, but the compiler is protesting the second to last line and
> I don't know why. What have I missed?
>
> Thanks
>
> For i = maxrows To 2 Step -1
> FormulaStr =
> "=IF(ISNA(VLOOKUP(cells(i,1),[NegsExceptions.xls]Sheet1!$A$1:$C$18,1,FALSE)),""x"",VLOOKUP(cells(i,1),[NegsExceptions.xls]Sheet1!$A$1:$C$18,1,FALSE))"
> Range(Cells(i, 5)).Formula = FormulaStr
> Next i
>

 
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
change colors in a range of excel cells based on another range of cells Bobbi Muck Microsoft Excel Programming 1 9th Apr 2010 03:47 AM
how to compute a range of cells based on another range of cells? =?Utf-8?B?SEFST0xE?= Microsoft Excel Worksheet Functions 1 30th Dec 2005 09:32 PM
how to compute a range of cells based on another range of cells? =?Utf-8?B?SEFST0xE?= Microsoft Excel Worksheet Functions 2 30th Dec 2005 07:55 PM
Copy a formula to a range of cells via VB6 using .Range(Cells(row,col), Cells(row,col)).Formula= statement Kevin Microsoft Excel Programming 7 5th Oct 2004 08:11 PM
Is there a range function (i.e. Max(range of cells)-Min(range of cells))?? ModelerGirl Microsoft Excel Misc 3 26th Jul 2004 10:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:04 AM.