Invalid Procedure Call - Trying to join using Mid and Instr

bravura

Board Regular
Joined
Jan 27, 2010
Messages
51
tblA has commodities such as ME Milled Rice, and tblB has just ME and second field with load factor

=Mid(tblA.Commodity, 1, InStr(1, " ", tblA.Commodity) - 1) = tblB.Commodity

[TABLE="width: 260"]
<tbody>[TR]
[TD]tblA[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]field1[/TD]
[TD]field2[/TD]
[TD]Commodity[/TD]
[/TR]
[TR]
[TD]abc[/TD]
[TD]123[/TD]
[TD]MR - Milled Rice[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]tblB[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Commodity[/TD]
[TD]LF[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]MR[/TD]
[TD]22[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Looks like you have the arguments to instr() in the wrong order: it should be (1, searched, sought). So ....

=
Code:
Mid(tblA.Commodity, 1, InStr(1, tblA.Commodity, " ") - 1) = tblB.Commodity
 
Last edited:
Upvote 0
not much here to go on, but one thing I'm pretty sure of is that you'll get that message if you try to pass a negative value to the Mid function. This could occur if the Instr function doesn't find the character that you're searching for, because you are subtracting 1 regardless. Are you certain the error occurs with the data you've shown?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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