Extracting a substring from an array, eliminating duplicates

Sevigny86

New Member
Joined
Apr 18, 2018
Messages
15
Hi everyone,

I'm trying to set something up here and I'm a little lost in my functions, hopefully someone can help out!

I have a dynamic array of a portfolio which has a series of symbols ex. OMCL-US (because it pulls data from a database that requires the "-US" portion). But now, I'm trying to dynamically refer to a worksheet which will hold specific data for that stock. I understand the Indirect function does not allow for symbols ex. "-" so I need to name my sheets ex. OMCL and not OMCL-US.

Consequently, when I create my table, pulling my unique stock list from my portfolio it comes out as ex. "OMCL-US" as thats how it is found in the data base. I would like the output to rather be "OMCL" instead of "OMCL-US" so that my indirect link can function properly.

Currently this is my formula to pull my data from the portfolio page:

=IFERROR(INDEX('Portfolio Weightings'!$B$10:$B$64,MATCH(0,INDEX(COUNTIF($A$2:A2,'Portfolio Weightings'!$B$10:$B$64),0,0),0)),0)

To pull my desired data I then refer to the output cell with:

=IF(A3=0,"",IFERROR(INDIRECT(B3&"!$b$10"),"N/A")

I know I can pull the required text before the "-" using:

=IF(A3=0,"",LEFT(A3, MIN(FIND("-", A3&"-"))-1))

But I would like to combine them so it outputs correctly right away, rather than use a second column to convert.

Thanks in advance! :)
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
=IF(A3=0,"",IFERROR(INDIRECT(B3&"!$b$10"),"N/A")

INDIRECT can refer to a sheet with a dash in its name, you simply have to treat it the same way you would if there was an embedded space... surround the name with apostrophes...

=IF(A3=0,"",IFERROR(INDIRECT("'"&B3&"'!B10"),"N/A"))
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

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