LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF Statements to Select Case??? Walter Excel Discussion (Misc queries) 2 December 2nd 09 08:00 PM
Case Statements in Excel 2003 Alex Excel Discussion (Misc queries) 3 April 3rd 08 10:34 PM
Using Select Case Statements Bob[_53_] Excel Programming 3 April 30th 04 08:58 PM
Limits on Case Statements Todd Huttenstine Excel Programming 4 April 14th 04 08:32 PM
Case Statements Todd Huttenstine Excel Programming 2 April 14th 04 04:35 PM


All times are GMT +1. The time now is 07:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"