+ Reply to Thread
Results 1 to 3 of 3

Case Select statements with "if" statements

Hybrid View

  1. #1
    Registered User
    Join Date
    06-03-2008
    Posts
    35

    Case Select statements with "if" statements

    Can you not use "if" statements in Case Select statements? If you can, will somebody help me figure out why I'm getting an error (Error '438') for the following code?

    Select Case shift1
        Case [1]
            If (wc1 = Cells(i, 1).Value) Then
                moveData = False
            End If
        Case [2]
            If wc1 = Cells(i - 1, 1).Value Then
                moveData = False
            End If
        Case [3]
            If wc1 = Cells(i - 2, 1).Value Then
                moveData = False
            End If
        Case Else
            moveData = True
        End Select

  2. #2
    Forum Contributor Stuie's Avatar
    Join Date
    09-17-2006
    Location
    Suffolk, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    432
    Hi compulsiveguile,

    As far as im aware you can use if in a select (not that i ever have so i could be wrong).

    but, what data type is shift1? if Integer then try case 1 instead of case [1].

    or if string case "1"
    There are only 10 types of people in the world:
    Those who understand binary, and those who don't!

  3. #3
    Registered User
    Join Date
    06-03-2008
    Posts
    35
    Quote Originally Posted by Stuie
    Hi compulsiveguile,

    As far as im aware you can use if in a select (not that i ever have so i could be wrong).

    but, what data type is shift1? if Integer then try case 1 instead of case [1].

    or if string case "1"
    It's always so simple... thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1