Type mismatch. Runtime Error 13

iqbal88

New Member
Joined
Dec 11, 2013
Messages
14
Hello, my friends I m trying to generate alphanumeric ID based on combobox value, but facing error. Type mismatch. Runtime Error 13. Please help me
Thanks in advnce

Code:
Option Explicit


Sub GenNextTID()
Dim ws As Worksheet
Dim lr As Long, x As Long
Dim myName As String, lstNum As Variant


Set ws = ThisWorkbook.Sheets("test_List")


If Me.ComboBox2.Value = "Bolod" Then
    myName = UCase("Lab")
    ElseIf Me.ComboBox2.Value = "Others" Then
    myName = UCase("MIS")
End If


lr = ws.Cells(Rows.Count, 1).End(xlUp).Row
For x = 2 To lr
    If Left(ws.Cells(x, 1), 3) = myName Then
        lstNum = Right(ws.Cells(x, 1), 3)
Next x
[B]lstNum = Format(lstNum + 1, "000") 'Error is here[/B]
Me.TextBox1.Text = myName & lstNum 

End Sub
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

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