Run time error : 13 "Type mismatch

MCE2014

New Member
Joined
Sep 15, 2014
Messages
21
Hi,

Can someone tell me where im going worng in this line of code:

Dim FindString As String

FindString = Sheets(cmbmachine.Value).Range("A1:E1").Value
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Is cmbmachine declared as a worksheet? If so, you don't need .value after it in the brackets i.e. Sheets(cmbmachine)

Dan
 
Upvote 0
Hi Danerida,

No it is a combobox on the userform.

Each worksheet is set as the fleet number of the machine

So i use the combobox value from cmbmachine as the search criteria when picking the worksheet the values and info is added to.
 
Last edited:
Upvote 0
Hi,

Can someone tell me where im going worng in this line of code:

Dim FindString As String

FindString = Sheets(cmbmachine.Value).Range("A1:E1").Value
Range("A1:E1") does not have a value, it has 5 values. So you can't put them all at once to a single String variable.

If you declared FindString as a Variant instead of String then your code would read the range values into an array:

A1 value in FindString(1,1)
B1 value in FindString(1,2)
C1 value in FindString(1,3)
etc
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,431
Members
452,326
Latest member
johnshaji

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