need to replace 3 digits if condition met

CRAIG20

Board Regular
Joined
Mar 20, 2006
Messages
225
Hi. I would like a formula


I have 2 rows of cells A&B. A contains a long number and B a reference.

Eg. If the cell in B4 says "ALL" I would like to replace the last 4 digits in A4 with "1234" If B4 is blank then it leaves A4 as it is.

Thanks in adavance.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Please be careful with your descriptions. ;)
- Thread title says replace 3 but post says replace 4
- "rows of cells A&B". A & B are columns, 1 & 2 are rows.

BTW, I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)


See if this is what you want

20 10 19.xlsm
ABC
1
2123456789ALL123451234
3986541ALL981234
4965321458965965321458965
Replace digits
Cell Formulas
RangeFormula
C2:C4C2=IF(B2="",A2,--(LEFT(A2,LEN(A2)-4)&1234))
 
Upvote 0
Please be careful with your descriptions. ;)
- Thread title says replace 3 but post says replace 4
- "rows of cells A&B". A & B are columns, 1 & 2 are rows.

BTW, I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)


See if this is what you want

20 10 19.xlsm
ABC
1
2123456789ALL123451234
3986541ALL981234
4965321458965965321458965
Replace digits
Cell Formulas
RangeFormula
C2:C4C2=IF(B2="",A2,--(LEFT(A2,LEN(A2)-4)&1234))
Thank you and apologies, I should have been clearer. Just one more thing. If I want to replace the first 3 of the last 4 digits but leave the 4th one. eg. replace 2224 with 3334? full length of digits is 18. can you let me know this formula?

Thanks again
 
Upvote 0

Forum statistics

Threads
1,214,632
Messages
6,120,649
Members
448,975
Latest member
sweeberry

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