PDA

View Full Version : Solved: Run-time error '13' on an If stmt



snowdyce
11-08-2012, 11:32 AM
Hello everyone,

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

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


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 :beerchug:

snowdyce
11-08-2012, 01:22 PM
Hey I have an update. I did some testing. When I left it:
If CurrentSubGroup = "Salaried Exempt"
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

snowdyce
11-08-2012, 01:39 PM
I was able to get it to work. My solution was to repeat the variable.
If CurrentSubGroup = "Salaried Exempt" Or CurrentSubGroup = "Salaried Non-Exempt" Or CurrentSubGroup = "Executives" Or CurrentSubGroup = "Global Mobility STA" Or CurrentSubGroup = "Salaried Exempt OT" Then