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