Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with an If statement VBA
Hi all, In my spreadsheet i want to populate a cell with a value dependent o the result of two other cells and I would like some help with the vb line to do this. I know it can be written as follows in 3 lines of code: If Range("A1").Value = "Referee" AND Range("B1").Value = "U21" The Range("G23").Value = "Value 1" If Range("A1").Value = "Referee" AND Range("B1").Value = "U19" The Range("G23").Value = "Value 1" If Range("A1").Value = "Referee" AND Range("B1").Value = "U17" The Range("G23").Value = "Value 1" but really what I want is to evaluate with one line of code to say i A1 = "Referee" AND B1 is any of "U21", "U19", "U17" then G23 "Value1" Hope I have made myself clear enough and any help would b appreciated. TIA Seamu -- SO ----------------------------------------------------------------------- SOS's Profile: http://www.excelforum.com/member.php...nfo&userid=540 View this thread: http://www.excelforum.com/showthread.php?threadid=26156 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with an If statement VBA
Hello, no Problem, do it like this: Code ------------------- If (Range("A1").Value = "Referee") AND (Range("B1").Value = "U21" Or Range("B1").Value = "U19" Or Range("B1").Value = "U17") Then Range("G23").Value = "Value 1" End I ------------------- Hope it's the solution you need.. -- falstaf ----------------------------------------------------------------------- falstaff's Profile: http://www.excelforum.com/member.php...fo&userid=1453 View this thread: http://www.excelforum.com/showthread.php?threadid=26156 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
IF statement inside a SUMIF statement.... or alternative method | Excel Worksheet Functions | |||
Reconcile Bank statement & Credit card statement & accounting data | Excel Worksheet Functions | |||
Embedding an OR statement in an IF statement efficiently | Excel Discussion (Misc queries) | |||
appending and IF statement to an existing IF statement | Excel Worksheet Functions | |||
Help please, IF statement/SUMIF statement | Excel Worksheet Functions |