Consulting

Results 1 to 3 of 3

Thread: Solved: Run-time error '13' on an If stmt

  1. #1
    VBAX Regular
    Joined
    Oct 2012
    Posts
    35
    Location

    Cool Solved: Run-time error '13' on an If stmt

    Hello everyone,

    I have an If Statement that is giving me a Run-time error '13': Type Mismatch. Here is the code:

    [VBA]Dim CurrentSubGroup as String
    Dim i, LastRow as Long

    Do Until i = LastRow
    CurrentSubGroup = ActiveSheet.Cells(i, 9).Value
    If CurrentSubGroup = "Executives" Or "Global Mobility STA" Or "Salaried Exempt" Or "Salaried Non-Exempt" Or "Salaried Exempt OT" Then
    End If
    i=i+1
    Loop
    [/VBA]

    I haven't put the code that will execute if true. Mu example, the first Column populates CurrentSubGroup as "Salaried Expense" so it should pass through the If. The runtime error pops when it get to the if with all the Or's. Am I doing sometime wrong? Thanks

  2. #2
    VBAX Regular
    Joined
    Oct 2012
    Posts
    35
    Location
    Hey I have an update. I did some testing. When I left it:
    [VBA]If CurrentSubGroup = "Salaried Exempt"[/VBA]
    It worked fine. As soon as I added one Or stmt it pops the error. Is there a way to get this to work without writing an if for each possible outcome when the action to be taken is the same.

    Thanks

  3. #3
    VBAX Regular
    Joined
    Oct 2012
    Posts
    35
    Location
    I was able to get it to work. My solution was to repeat the variable.
    [VBA]If CurrentSubGroup = "Salaried Exempt" Or CurrentSubGroup = "Salaried Non-Exempt" Or CurrentSubGroup = "Executives" Or CurrentSubGroup = "Global Mobility STA" Or CurrentSubGroup = "Salaried Exempt OT" Then[/VBA]

Posting Permissions

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