Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 29th, 2014, 09:40 AM
Registered User
 
Join Date: Apr 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation Formula not working in VBA, but works in cell

I am doing a conditional statement and I have automated my spreadsheet using VBA. Everything works fine until it comes to this one formula. I am guessing it has to do with the text strings. I have tried using & Chr(34) & before and after and it's not working either.

Here's the formula:
=IF(E2="RIA Review",IF(G2<=4,"Green",IF(G2=5,"Yellow","Red")), IF(E2="Delivery",IF(I2<=-7,"Green",IF(I2=-1,"Yellow","Red")),IF(E2="Launch/Close",IF(I2>=121,"Red",IF(I2>=111,"Yellow",IF(I2> =100,"Green","N/A"))),IF(OR(E2="Intent",E2="AE Review",E2="Initial Review",E2="AE Disposition"),IF(G2<=8,"Green",IF(OR(G2=9,G2=10)," Yellow",IF(G2>=11,"Red")))))))

Here's the code in VBA (it changes the cell references, which I still have a hard time knowing if it's talking about the right cell)
Range("H2").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-3]=""RIA Review"",IF(RC[-1]<=4,""Green"",IF(RC[-1]=5,""Yellow"",""Red"")),IF(RC[-3]=""Delivery"",IF(RC[1]<=-7,""Green"",IF(RC[1]=-1,""Yellow"",""Red"")),IF(RC[-3]=""Launch/Close"",IF(RC[1]>=121,""Red"",IF(RC[1]>=111,""Yellow"",IF(RC[1]>=100,""Green"",""N/A""))),IF(OR(RC[-3]=""Intent"",RC[-3]=""AE Review"",RC[-3]=""Initial Review"",RC[-3]=""AE Disposition"")," & _
"]<=8,""Green"",IF(OR(RC[-1]=9,RC[-1]=10),""Yellow"",IF(RC[-1]>=11,""Red"")))))))"

Any help would be great!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell formula query Neal Excel VBA 1 October 19th, 2009 12:53 PM
Excel formula not working in vba yogeshyl Excel VBA 2 December 12th, 2007 02:27 AM
Using Formula on Active Cell manojkumarsoni Excel VBA 3 August 26th, 2007 08:56 AM
Excel formula not working in VBA yogeshyl Excel VBA 2 July 19th, 2007 03:57 AM
What would the formula "=+D4" do in a cell? BrianWren Excel VBA 2 February 2nd, 2006 03:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.