Adding strings to current text

gogent

New Member
Joined
Aug 2, 2017
Messages
9
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi, I'm trying to figure out what's the best way to add the following strings.

1. I've a list of incidents on a spreadsheet.

INC000010
INC000011
INC000012
INC000013
INC000014
INC000015

2. I want to add Incident ID*+' = " before each incident follow by a " Or.
I want it to look like this on a single cell.
'Incident ID*+' = "INC000010" Or 'Incident ID*+' = "INC000011" Or 'Incident ID*+' = "INC000012" Or 'Incident ID*+' = "INC000013" Or 'Incident ID*+' = "INC000014" Or 'Incident ID*+' = "INC000015"

Would the concatenate function be the best way to achieve this?
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
do you want a lengthy formula or a VBA approach?
Where do you want the resultant answer ?
Where are the current list of incidents listed ?
As you can see, more information gets better results !
 
Upvote 0
In addition to @Michael M question, can you update your profile to indicate what version of Excel you are on.

I am not clear on what output you want but if you have Excel 365 something like this might work for you.

Excel Formula:
="'Incident ID*+' = " &TEXTJOIN(" Or 'Incident ID*+' = ",TRUE,$A$5:$A$10)
 
Upvote 0
Hi Michael,

do you want a lengthy formula or a VBA approach? Formula would be ideal since my work have some VBA restrictions
Where do you want the resultant answer ? Not sure what you mean by this.
Where are the current list of incidents listed ? Is listed on a spreadsheet.
As you can see, more information gets better results !


Thanks, Alex that's great! Your formula almost got it to where I want it to be. However, the quotes are not around the incidents. I tried to add some quotes to your formula but keep getting error messages.
Mine
'Incident ID*+' = "INC000010" Or 'Incident ID*+' = "INC000011" Or 'Incident ID*+' = "INC000012" Or 'Incident ID*+' = "INC000013" Or 'Incident ID*+' = "INC000014" Or 'Incident ID*+' = "INC000015"

Your
'Incident ID*+' = INC000010 Or 'Incident ID*+' = INC000011 Or 'Incident ID*+' = INC000012 Or 'Incident ID*+' = INC000013 Or 'Incident ID*+' = INC000014 Or 'Incident ID*+' = INC000015
 
Upvote 0
If you used VBA
Where do you want the resultant answer ? Not sure what you mean by this.....you would ned to tell us which cell / sheet to place the answer ?
Where are the current list of incidents listed ? Is listed on a spreadsheet.....sheet name/cell location ?
 
Upvote 0
I couldn't find an elegant way of doing it but this should get you there:-

Excel Formula:
=SUBSTITUTE(
        SUBSTITUTE("'Incident ID*+' = "&TEXTJOIN(" Or 'Incident ID*+' = ",TRUE,$A$5:$A$10),
        " INC"," ""INC"),
" Or",""" Or")
& """"
 
Upvote 0
Excel Formula:
=SUBSTITUTE(SUBSTITUTE("'Incident ID*+' = "&TEXTJOIN(" Or 'Incident ID*+' = ",TRUE,$A$1:$A$6)," INC"," ""INC")," Or",""" Or")& """"

Thank you so much. I think this is it and will try it when I return back to work next Monday. Thank you to you both for your time and have a great day!
 
Upvote 0
Upvote 0

Forum statistics

Threads
1,214,400
Messages
6,119,292
Members
448,885
Latest member
LokiSonic

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