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 |
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 |
All times are GMT +1. The time now is 05:15 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com