Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
compare x to values in a range
X is a random integer
I want to compare X to the value in each cell in the range C965:C989 and if X matches the value in any one of those cells go back to the routine where x is generated again. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
compare x to values in a range
d.e.lindstrom wrote:
X is a random integer I want to compare X to the value in each cell in the range C965:C989 and if X matches the value in any one of those cells go back to the routine where x is generated again. Your question pretty much answers itself. This is an English-to-VBA translation: Dim cel As Range jump_target: ' X is a random integer X = Int(Rnd * 10) For Each cel In Range("C965:C989") ' I want to compare X to the value in each cell in the range ' C965:C989 and if X matches the value in any one of those cells go ' back to the routine where x is generated again. If X = cel.Value Then GoTo jump_target Next Stop Note that some people will bitch because OH NOES TEH EEEEEVIL GOTO but it's short, simple, and it works. (You can avoid GOTO via DO/LOOP or similar.) -- The good news is that events are unfolding just as foretold. The bad news is that the story ends in our utter ruin! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
compare x to values in a range
On Saturday, April 25, 2015 at 7:30:53 AM UTC+10, wrote:
X is a random integer I want to compare X to the value in each cell in the range C965:C989 and if X matches the value in any one of those cells go back to the routine where x is generated again. thx it works |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Compare values of cells in a range | Excel Programming | |||
Find duplicate values in column K then compare cells range of dups | Excel Programming | |||
How do I compare a result to a range of values? | Excel Worksheet Functions | |||
Compare alpha and numeric values within a range | Excel Worksheet Functions |