If column A contains then add B

Dharmalingam

New Member
Joined
Jan 8, 2014
Messages
34
Hi,

Could any one pls help me here, im having sheet with below values in column A (it contains n number of values)
<clientname>RBS</clientname>
<customerid>98</customerid>
<customerreference>H12</customerreference>
<customerid>A34</customerid>
<customerreference>WR2</customerreference>
<clientname>TSQ</clientname>
<clientcode></clientcode>
<clientcontact>98765432<clientcontact></clientcontact></clientcontact>
<clientname></clientname>

<tbody>
</tbody>

If Column A contains the word Clientname then i need to add 1 into column B, in same way if Column A contains the word CustomerId then i need to add 2 into its respective Column B, like below could any one pls.

<clientname>RBS</clientname>

<tbody>
</tbody>
1
<customerid>98</customerid>

<tbody>
</tbody>
2
<customerreference>H12</customerreference>

<tbody>
</tbody>
<customerid>A34</customerid>

<tbody>
</tbody>
2
<customerreference>WR2</customerreference>

<tbody>
</tbody>
<clientname>TSQ</clientname>

<tbody>
</tbody>
1
<clientcode></clientcode>

<tbody>
</tbody>
<clientcontact>98765432<clientcontact></clientcontact></clientcontact>

<tbody>
</tbody>
<clientname></clientname>

<tbody>
</tbody>
1

<tbody>
</tbody>

Thank you very much for your help.

Thanks,
Dharma.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Marcelo Branco

MrExcel MVP
Joined
Aug 23, 2010
Messages
17,100
Office Version
  1. 365
  2. 2016
  3. 2010
Platform
  1. Windows
Try

B1
=IF(ISNUMBER(SEARCH("clientname",A1)),1,IF(ISNUMBER(SEARCH("customerid",A1)),2,""))
copy down

M.
 
Upvote 0

Forum statistics

Threads
1,195,619
Messages
6,010,736
Members
441,567
Latest member
Flitbee

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