Run Type Error 13-help needed

HYKE

Active Member
Joined
Jan 31, 2010
Messages
373
Hi,

I have this code which giving me a run time error 13, can't figure out the reason why...
Code:
Private Sub ComboBox1_Change()
 Dim B As Long
    With Sheet2
        [COLOR=red] B = Application.Match(ComboBox1.Value, .Range("B:B"), False)-this part is highlighted on runtime error
[/COLOR]         Label8.Caption = .Cells(B, 3).Value
    End With
End Sub
Private Sub CommandButton1_Click()
 Dim r As Long
    With Sheet2
         r = Application.Match(ComboBox1.Value, .Range("B:B"), False)
        .Cells(r, 4).Value = .Cells(r, 4).Value + Val(TextBox2.Value)
        .Cells(r, 5).Value = .Cells(r, 5).Value + Val(TextBox3.Value)
        .Cells(r, 6).Value = .Cells(r, 6).Value + Val(TextBox4.Value)
        .Cells(r, 7).Value = TextBox5.Value
        .Cells(r, 8).Value = TextBox6.Value
        .Cells(r, 9).Value = TextBox7.Value
    If OptionButton1 = True Then
        .Cells(r, 27).Value = .Cells(r, 27).Value + Val(TextBox8.Value)
        .Cells(r, 28).Value = TextBox9.Value
        .Cells(r, 29).Value = .Cells(r, 29).Value + Val(TextBox10.Value)
        .Cells(r, 30).Value = TextBox11.Value
        .Cells(r, 31).Value = .Cells(r, 31).Value + Val(TextBox12.Value)
        .Cells(r, 32).Value = TextBox13.Value
    End If
    
       
        TextBox2.Value = ""
        TextBox3.Value = ""
        TextBox4.Value = ""
        TextBox5.Value = ""
        TextBox6.Value = ""
        TextBox7.Value = ""
        ComboBox1.Value = ""
        ComboBox1.SetFocus
        Range("a1").Select
       
    End With
End Sub

Thanks for the help

HYKE
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
That will error if a match is not found. Maybe try like this

Code:
Private Sub ComboBox1_Change()
 Dim B As Variant
    With Sheet2
         B = Application.Match(ComboBox1.Value, .Range("B:B"), 0)
         If IsNumber(B) Then Label8.Caption = .Cells(B, 3).Value
    End With
End Sub
 
Upvote 0
Hi Vog,

The code is giving me a compiler error-sub function not defined
Code:
Private Sub ComboBox1_Change()
Dim B As Variant
    With Sheet2
         B = Application.Match(ComboBox1.Value, .Range("B:B"), 0)
         If [COLOR=red]IsNumber[/COLOR](B) Then Label8.Caption = .Cells(B, 3).Value
    End With
End Sub

Thanks,

HYKE
 
Upvote 0
Thanks, now it is working fine.....Just a question though-what is the difference in IsNumber to IsNumeric?
 
Upvote 0
ISNUMBER is a worksheet function.

IsNumeric is the VBA equivalent.

Why they had to use different names I do not know - it just leads to confusion on my part :confused:
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,555
Members
452,928
Latest member
101blockchains

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top