Best approach to using an Array

phownz

New Member
Joined
Jul 28, 2021
Messages
21
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I have a problem that I'm trying to find the best solution for - I'm trying to avoid VBA because I don't have too much experience with it. I was hoping for some advice on the best way to tackle this, as I've been looking into a few options but I don't know what the best approach is necessarily.

I have "Name" and "Company Name" - for each Company Name I need to prepend the Name with a different value for every individual company. For instance, "TELCO" would create "MMA_John_Smith", "MMA_Jack_Jones", "MMA_John_Doe" and "iWorks" would create "Apple_Jane_Smith", "Apple_Jane_Doe" and so on.

NameCompany Name
John SmithTELCO
Jack JonesTELCO
John DoeTELCO
Jane SmithiWorks
Jane DoeiWorks

I've not used arrays before in Excel but I was doing some reading/watching tutorials and it wasn't quite what I needed. I was hoping/assuming I would have a separate master type sheet with the Company Name and its associated prepends, something like below (these will be multiple companies, just using two for the example on "Sheet3"):

Company NamePrepend value
TELCOMMA_
iWorksApple_

I played around with some formulas and managed to get the result I wanted but only for a single cell, when I dragged the formula down it would still refer to the cell value as opposed to a range.

=IF(B5=Sheet3!A3,Sheet3!B3,"error") so I think I need to add in a "$" variable somewhere but can't quite get the desired result.

Maybe I'm way off... in any case, if anyone has any reading or watching material for this problem or best approach advice it would be appreciated.

Thanks in advance.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Something like this?

22 02 01.xlsm
AB
1Company NamePrepend value
2TELCOMMA_
3iWorksApple_
4
Master


22 02 01.xlsm
ABC
1NameCompany NameResult
2John SmithTELCOMMA_John_Smith
3Jack JonesTELCOMMA_Jack_Jones
4John DoeTELCOMMA_John_Doe
5Jane SmithiWorksApple_Jane_Smith
6Jane DoeiWorksApple_Jane_Doe
Prepend
Cell Formulas
RangeFormula
C2:C6C2=SUBSTITUTE(VLOOKUP(B2,Master!A$2:B$20,2,0)&A2," ","_")
 
Upvote 0
Hi Peter,

This is looking exactly right!

Give me a chance to break it down and play around and I will confirm but results wise it is correct.

Thank you!
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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