#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Select Case

Your points are well taken. Thanks. Here is the amended code incorporating
your suggestions...

Public Sub Username2Line()
Dim rng As Range
Dim IsCorrect As Boolean
For Each rng In Range(Range("H2"), Cells(Rows.Count, "A"). _
End(xlUp).Offset(0, 7))
If Len(rng.Value) Then
Select Case rng.Value
Case "MFG1"
IsCorrect = rng.Offset(0, 1).Value = "10FS"
Case "MFG11"
IsCorrect = rng.Offset(0, 1).Value = "80FS"
Case "MFG15"
IsCorrect = rng.Offset(0, 1).Value = "VTFS" Or _
rng.Offset(0, 1).Value = "TSFS" Or _
rng.Offset(0, 1).Value = "LUMFS"
Case "MFG16"
IsCorrect = rng.Offset(0, 1).Value = "STGFS"
Case "MFG17"
IsCorrect = rng.Offset(0, 1).Value = "35FS"
Case "MFG18"
IsCorrect = rng.Offset(0, 1).Value = "DPFS"
Case "MFG4", "MFG7"
IsCorrect = rng.Offset(0, 1).Value = "70FS"
Case "MFG5"
IsCorrect = rng.Offset(0, 1).Value = "VTFS"
Case Else
IsCorrect = False
End Select
If IsCorrect Then
rng.Offset(0, 2).Value = "Correct"
Else
rng.Offset(0, 2).Value = "Incorrect Location"
IsCorrect = False
End If
End If
Next
End Sub

--
Rick (MVP - Excel)


"Dana DeLouis" wrote in message
...
Hi. Perhaps combine the two 70FS's.

Case "MFG4", "MFG7"
IsCorrect = rng.Offset(0, 1).Value = "70FS"

Not sure how the data is set up, but it appears that the Op will have to
make sure that at least one of the Cases is Run. (Perhaps add an Case
Else)
The reason is that if IsCorrect is set to True, and the next pass does not
meet any Case Statements, then IsCorrect still remains set to True.
Maybe...

If IsCorrect Then
rng.Offset(0, 2).Value = "Correct"
IsCorrect = False
Else
...etc

= = = = =
Just an idea.
Dana DeLouis


Rick Rothstein wrote:
Code Correction.
======================

My previously posted code does not work; this modification to it does...

Public Sub Username2Line()
Dim rng As Range
Dim IsCorrect As Boolean
For Each rng In Range(Range("H2"), Cells(Rows.Count, "A"). _
End(xlUp).Offset(0, 7))
If Len(rng.Value) Then
Select Case rng.Value
Case "MFG1"
IsCorrect = rng.Offset(0, 1).Value = "10FS"
Case "MFG11"
IsCorrect = rng.Offset(0, 1).Value = "80FS"
Case "MFG15"
IsCorrect = rng.Offset(0, 1).Value = "VTFS" Or _
rng.Offset(0, 1).Value = "TSFS" Or _
rng.Offset(0, 1).Value = "LUMFS"
Case "MFG16"
IsCorrect = rng.Offset(0, 1).Value = "STGFS"
Case "MFG17"
IsCorrect = rng.Offset(0, 1).Value = "35FS"
Case "MFG18"
IsCorrect = rng.Offset(0, 1).Value = "DPFS"
Case "MFG4"
IsCorrect = rng.Offset(0, 1).Value = "70FS"
Case "MFG5"
IsCorrect = rng.Offset(0, 1).Value = "VTFS"
Case "MFG7"
IsCorrect = rng.Offset(0, 1).Value = "70FS"
End Select
If IsCorrect Then
rng.Offset(0, 2).Value = "Correct"
Else
rng.Offset(0, 2).Value = "Incorrect Location"
End If
End If
Next
End Sub


Reply
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
Can I use Select Case to do this? ChipButtyMan Excel Programming 7 October 19th 08 04:09 PM
Case without Select Case error problem Ayo Excel Discussion (Misc queries) 2 May 16th 08 03:48 PM
End Select without Select Case, Block If without End If errors Atreides Excel Programming 12 November 17th 06 05:10 PM
Case Select Bill Excel Programming 10 January 8th 05 05:02 PM


All times are GMT +1. The time now is 09:31 PM.

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

About Us

"It's about Microsoft Excel"