I have a basic If ElseIf statement I'm trying to loop over a few hundred rows. The If/Else statement itself works until I try and Loop it (which I've included below). When I run it, it gives me a run time error "13" -type mismatch. I Initially set MyCell
as a String
until I had this error arise. Then I figured setting MyCell
as a Variant
I would be able to avoid this situation but it's still returning the RTE 13.
Sub code_reassign()
Dim Count As Integer
Dim MyCell As Variant
Count = 1
Do While Count < 10
MyCell = ActiveCell.Value
If MyCell = "Busycotypus canaliculatus" Then
ActiveCell.Offset(0, -1).Value = "N106"
ElseIf MyCell = "Busycon carica" Then
ActiveCell.Offset(0, -1).Value = "N104"
ElseIf MyCell = "Busycon perversum" Or "Busycon sinistrum" Then
ActiveCell.Offset(0, -1).Value = "N103"
ElseIf MyCell = "Busycotypus spiratus" Then
ActiveCell.Offset(0, -1).Value = "N107"
Else
End If
ActiveCell.Offset(1, 0).Select
Count = Count + 1
Loop
End Sub
I'm still super new to VBA but have been thrown in the deep end at work. I'm doing what I can and studying the basics at home at nights to try and catch up. Any insight as to why the loop is creating a problem with mismatching would be highly appreciated.