Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
emulating if else Like statements with case
I have been given code of:
Do Until Selection = "" If Selection Like "A*" Then Selection.FormulaR1C1 = "AL" ElseIf Selection Like "G*" Then Selection.FormulaR1C1 = "GL" ElseIf Selection Like "P*" Then Selection.FormulaR1C1 = "PET" ElseIf Selection Like "B*" Then Selection.FormulaR1C1 = "BM" ElseIf Selection Like "1*" Then Selection.FormulaR1C1 = "PET" ElseIf Selection Like "2*" Then Selection.FormulaR1C1 = "HDPE" Else End If Selection.Offset(1, 0).Select Loop 'Until Selection = "" and was thinking of changing to: Dim c As String Do Until Selection = "" c = Selection Select Case c Case "A" To "az" Selection.FormulaR1C1 = "AL" Case "G" To "gz" Selection.FormulaR1C1 = "GL" Case "P" To "pz" Selection.FormulaR1C1 = "PET" Case "B" To "Bz" Selection.FormulaR1C1 = "BM" Case "1" To "1z" Selection.FormulaR1C1 = "PET" Case "2" To "2z" Selection.FormulaR1C1 = "HDPE" Case else end select Selection.Offset(1, 0).Select Loop 'Until Selection = "" I was wondering if their would be a more efficient way of doing this? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
IF Statements to Select Case??? | Excel Discussion (Misc queries) | |||
Case Statements in Excel 2003 | Excel Discussion (Misc queries) | |||
Using Select Case Statements | Excel Programming | |||
Limits on Case Statements | Excel Programming | |||
Case Statements | Excel Programming |