Again another Run Time Error 13

HYKE

Active Member
Joined
Jan 31, 2010
Messages
373
Hi There,

I have made a new userform (userform4) and assigned it to sheet 8. However, the code below is giving me a runtime error 13. I have tried naming the userform4.combobox1 but still is giving me the same error. What could be the reason behind now?
Dim r As Long
With Sheet8
r = Application.Match(UserForm4.ComboBox1.Value, .Range("F:F"), False)

.Cells(r, 17).Value = TextBox2.Value
.Cells(r, 18).Value = TextBox3.Value
.Cells(r, 19).Value = TextBox4.Value
.Cells(r, 29).Value = TextBox5.Value
.Cells(r, 30).Value = TextBox6.Value



TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""


Rows(r).Select
UserForm4.ComboBox1.SetFocus

End With
'ErrHandler:
'If Err.Number = 13 Then
' MsgBox "No Data to Display on System Stock!", vbExclamation, "Update Sheet"
' End If
End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
re-posting the code
Code:
 Dim r As Long
    With Sheet8
        [COLOR=red] r = Application.Match(UserForm4.ComboBox1.Value, .Range("F:F"), False)
[/COLOR]        
        .Cells(r, 17).Value = TextBox2.Value
        .Cells(r, 18).Value = TextBox3.Value
        .Cells(r, 19).Value = TextBox4.Value
        .Cells(r, 29).Value = TextBox5.Value
        .Cells(r, 30).Value = TextBox6.Value
        
        
       
        TextBox2.Value = ""
        TextBox3.Value = ""
        TextBox4.Value = ""
        TextBox5.Value = ""
        TextBox6.Value = ""
        
        
        Rows(r).Select
        UserForm4.ComboBox1.SetFocus
       
    End With
'ErrHandler:
    'If Err.Number = 13 Then
   ' MsgBox "No Data to Display on System Stock!", vbExclamation, "Update Sheet"
   ' End If
End Sub
 
Upvote 0
Are you getting an error on letters? I could see maybe an issue where it is trying to match a number with a text number and that would not match and could produce that error. Does this work?

r = Application.Match(clng(UserForm4.ComboBox1.Value), .Range("F:F"), False)

But again this can only be used for numbers.
 
Upvote 0
Hi,

Yes your code works with number, but is not with text and numbers. Is it possible to code to work for both?

Thanks,
 
Upvote 0
I would format column F as text. You may need to use text to columns to actually set it as text.

Otherwise you could do something like:

if isnumeric(UserForm4.ComboBox1.Value) then
r = Application.Match(clng(UserForm4.ComboBox1.Value), .Range("F:F"), False)
else
r = Application.Match(UserForm4.ComboBox1.Value, .Range("F:F"), False)
end if

Hope that helps.
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,628
Members
452,933
Latest member
patv

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