Best way to find a partial string in a row of data ?

Sparkle99

Board Regular
Joined
May 22, 2009
Messages
113
I need to find a partial string in row 1 of a sheet
e.g. find "Item.Value" where E1 is "Item.Value01", F1 is "Item.Value02" etc..

I need to return 'E' or number 5 to indicate the column.

I've written a function that uses Application.WorksheetFunction.Find - but this doesn't seem to work.

Code...
findval = Application.WorksheetFunction.Find(MatchVal, "'Item#'!A1")

Where I have a loop to substitute the cell value, the sheet is called Item# and the value is contained in the string MatchVal.
Anyone spot my mistake ? There must be one !

Cheers for your help.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,484
To get the 1st occurence ONLY use:
Excel Workbook
ABCDEFGHIJK
1ktq-hddabcnnnrnmItem.Value01Item.Value02Find FirstFound In
2occurrence ofColumn #
3Item.Value5
Sheet1
Excel 2007
Cell Formulas
RangeFormula
K3=MATCH("Item.Value*",A1:F1,0)
 

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,484
Modified.... to

=MATCH(J3,A1:F1,0)
where J3 is:
Item.Value*, or Item.Value01, or Item.Value02
 

Sparkle99

Board Regular
Joined
May 22, 2009
Messages
113
Thanks Jim, just after I submitted my question I realised this would work.

But, how would I find the last cell that also matches the string ?
 

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,484
This might be a better way;
Excel Workbook
ABCDEFGHIJK
1ktq-hddabcnnnrnmItem.Value01Item.Value02Find FirstFound In
2occurrence ofColumn #
3Item.Value015
4
5Item.Value026
Sheet1
Excel 2007
Cell Formulas
RangeFormula
K3=LOOKUP(2,1/(A$1:F$1=J3),COLUMN(A$1:F$1))
K5=LOOKUP(2,1/(A$1:F$1=J5),COLUMN(A$1:F$1))
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,683
Messages
5,838,793
Members
430,569
Latest member
sbardelli

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
Top