stmarl

New Member
Joined
Jul 13, 2018
Messages
4
Run-Time Error '13':
Type mismatch

Code:
[I]Private Sub CommandButton2_Click()[/I]
[I]Dim CheckTrack As String[/I]
[I]Dim Vlookupticket As String[/I]

[I]CheckTrack = TicketNumber.Value[/I]
[I]Vlookupticket = Application.VLookup(CheckTrack, Sheet2.Range("A:B"), 2, False)[/I]

[I]If IsError(Vlookupticket) Then[/I]
[I]EscalationTitle.Value = "No Ticket found"[/I]
[I]Else[/I]
[I]EscalationTitle.Value = Vlookupticket[/I]

[I]End If[/I]

[I]End Sub[/I]
 

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: Vlookup error in vba Help Needed

Hi, welcome to the forums

You set a lot of variables there, and relying on Vlookup for your intended result isn't necessary

Code:
Private Sub CommandButton2_Click()
Dim findItem As Range


Set findItem = Sheet2.Range("A:A").Find(TicketNumber.Value, Sheet2.Range("A1"))


If Not findItem Is Nothing Then
    EscalationTitle.Value = findItem.Offset(, 1).Value
Else
    EscalationTitle.Value = "No Ticket found"
End If


End Sub

Test this on a copy of your workbook and see if it yields the desired results.
 
Upvote 0
Re: Vlookup error in vba Help Needed

Where are TicketNumber and EscalationTitle set and valued?
If you Dim VlookupTicket as a string then you will get a type mismatch error. Try Dim VlookupTicket as Variant.
 
Upvote 0

Forum statistics

Threads
1,215,087
Messages
6,123,046
Members
449,092
Latest member
ikke

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