Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
If Statement with multiple qualifiers
Hopefully my title is somewhat descriptive of my question. I have one column (B) of text data. I want to write a macro that will go down this column and look at the text one row at a time. Depending on what the cell's content is, it will then assign a number to the adjacent column (C). My macro works fine as long as I only have one qualifier in my If statement. For example, my activecell is the empty column that I want to assign the number to. This will work: Do If ActiveCell.Offset(0,-1) = "BALL" Then Activecell = 3 ElseIf ActiveCell.Offset(0,-1) = "HAMMER" Then Activecell = 8 etc. EndIf ActiveCell.Offset(1,0).Activate Loop Until.... What I want is: Do If ActiveCell.Offset(0,-1) = "BALL" Or "MOUSE" Or "STAPLER" Then Activecell = 3 ElseIf ActiveCell.Offset(0,-1) = "HAMMER" Or "PEN" Then Activecell = 8 etc. EndIf ActiveCell.Offset(1,0).Activate Loop Until.... The above gets a mismatch error. How do I arrange my possible options to condense my code so that I don't have to have an elseif statement for every single option? Thanks for any responses. -- mworth01 ------------------------------------------------------------------------ mworth01's Profile: http://www.excelforum.com/member.php...fo&userid=8991 View this thread: http://www.excelforum.com/showthread...hreadid=399472 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Text Qualifiers | Excel Discussion (Misc queries) | |||
Multiple Qualifiers | Excel Discussion (Misc queries) | |||
How do I set up an IF formula with multiple qualifiers? | Excel Discussion (Misc queries) | |||
Table lookup using multiple qualifiers | Excel Discussion (Misc queries) | |||
XL2K Qualifiers | Excel Programming |