Run-time error '13' Type mismatch

Mahmoud Sayed

New Member
Joined
Sep 29, 2021
Messages
19
Office Version
  1. 2010
Platform
  1. Windows
I have a search function, and when you do not find what you are looking for, an error appears. What is the solution to this problem?
this function
VBA Code:
Private Sub CommandButton4_Click()
Sheet2.Range("J2").Value = Sheet1.Range("E3").Value
Dim L As Integer
L = Sheet2.Range("K2").Value           'error here

Sheet1.Range("D5").Value = Sheet2.Cells(L, "B").Value
Sheet1.Range("D7").Value = Sheet2.Cells(L, "C").Value
Sheet1.Range("D9").Value = Sheet2.Cells(L, "D").Value
Sheet1.Range("D11").Value = Sheet2.Cells(L, "E").Value
Sheet1.Range("G5").Value = Sheet2.Cells(L, "F").Value
Sheet1.Range("G7").Value = Sheet2.Cells(L, "J").Value
Sheet1.Range("G9").Value = Sheet2.Cells(L, "H").Value
Sheet1.Range("G11").Value = Sheet2.Cells(L, "I").Value
Sheet1.Range("G13").Value = Sheet2.Cells(L, "J").Value




End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
It means that whatever is in K2 cannot be converted to an integer. What do you want to happen in that situation?
 
Upvote 0
It means that whatever is in K2 cannot be converted to an integer. What do you want to happen in that situation?
The search comes without error when it is the same name, I want the result to be printed in the #Listbox everything that is similar to the result or a duplicate result
Listbox here
VBA Code:
Private Sub ListBox1_Click()
Me.Cells(L, "B").Text = Me.ListBox1.Column(0)
Me.Cells(L, "C").Text = Me.ListBox1.Column(1)
Me.Cells(L, "D").Text = Me.ListBox1.Column(2)
Me.Cells(L, "E").Text = Me.ListBox1.Column(3)
Me.Cells(L, "F").Text = Me.ListBox1.Column(4)
Me.Cells(L, "J").Text = Me.ListBox1.Column(5)
Me.Cells(L, "H").Text = Me.ListBox1.Column(6)
Me.Cells(L, "I").Text = Me.ListBox1.Column(7)



 
End Sub
 
Upvote 0
There is no searching in your code. Nothing you are saying makes any sense (to me at least).

Please try to remember that nobody here can see your workbook, or has any prior knowledge of what you are doing, so you need to be as clear as possible. All I can say from what you have posted is that you will get that error if the value in cell K2 on Sheet2 is not a number.
 
Upvote 0
There is no searching in your code. Nothing you are saying makes any sense (to me at least).

Please try to remember that nobody here can see your workbook, or has any prior knowledge of what you are doing, so you need to be as clear as possible. All I can say from what you have posted is that you will get that error if the value in cell K2 on Sheet2 is not a number.
I need a little help from you, so that the search result is shown in Listbox, and is there any technical error in the previous codes
 
Upvote 0
Again, there is no searching in your code. You are just assigning values from cell to cell. I cannot help you with the little information you have provided.
 
Upvote 0
Again, there is no searching in your code. You are just assigning values from cell to cell. I cannot help you with the little information you have provided.
What do you need from me to help?
If you want me to send you the entire project on Gmail, I will send it to him.
 
Upvote 0
I just need you to explain what you are actually doing. You keep saying you are searching, but there is no searching at all in the code you posted, nor is there any code to populate a listbox (the code you posted goes from a listbox to a range)

As I've already said twice, the error you are currently getting is because whatever is in K2 is not a number. Since we don't know what is, or should be, in K2, we can't really tell you any more than that.
 
Upvote 0
I just need you to explain what you are actually doing. You keep saying you are searching, but there is no searching at all in the code you posted, nor is there any code to populate a listbox (the code you posted goes from a listbox to a range)

As I've already said twice, the error you are currently getting is because whatever is in K2 is not a number. Since we don't know what is, or should be, in K2, we can't really tell you any more than that.
I do not know how to explain it to you, can I contact you in private, and send you the project so that you can understand and correct what I am saying
 
Upvote 0
No, that is against forum policy.

Start by just telling me what should be in K2, and what is there when the error occurs.
 
Upvote 0

Forum statistics

Threads
1,215,607
Messages
6,125,818
Members
449,262
Latest member
hideto94

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