If Formula

kbendelac

New Member
Joined
Aug 9, 2020
Messages
38
Office Version
  1. 2019
Platform
  1. Windows
I am looking to create a formula that would remove the first 2 digits of a series and if a text string contains the word Anjou replace with 78 or Moncton replace with 83.

As an example:
Cell A2 contains 704705041 and B2 will need to read 784705041/834705041 where 70 (first 2 digits of A2) will be replaced with either 78 for Anjou or 83 for Moncton in B2

1720106615297.png
 

Attachments

  • 1720106578537.png
    1720106578537.png
    23.7 KB · Views: 2

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Please try
=IF(ISNUMBER(SEARCH("Anjou",D2)),REPLACE(A2,1,2,78),IF(ISNUMBER(SEARCH("Moncton",D2)),REPLACE(A2,1,2,83),A2))
 
Upvote 0
Another option
Excel Formula:
=REPLACE(A2,1,2,IF(ISNUMBER(SEARCH("Anjou",D2)),78,IF(ISNUMBER(SEARCH("Moncton",D2)),83,"")))
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Another option
Excel Formula:
=REPLACE(A2,1,2,IF(ISNUMBER(SEARCH("Anjou",D2)),78,IF(ISNUMBER(SEARCH("Moncton",D2)),83,"")))

I think this will chop off the first 2 characters if neither text is found.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,179
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