ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Replace data to right of string problem (https://www.excelbanter.com/excel-worksheet-functions/447721-replace-data-right-string-problem.html)

Jayjones

Replace data to right of string problem
 
Hi guys - trying to replace or substitute data to almost right of string ie want excel to always count 5 characters from right of cell but then only replace 4 of the characters with XXXX leaving last character as it was eg 1234abcde becomes 1234XXXXe or 123456abcdesfgh becomes 123456abcdXXXXh. I have tried right function with replace but can't manage to leave last digit intact. The replacing text is always XXXX

Spencer101

Quote:

Originally Posted by Jayjones (Post 1607610)
Hi guys - trying to replace or substitute data to almost right of string ie want excel to always count 5 characters from right of cell but then only replace 4 of the characters with XXXX leaving last character as it was eg 1234abcde becomes 1234XXXXe or 123456abcdesfgh becomes 123456abcdXXXXh. I have tried right function with replace but can't manage to leave last digit intact. The replacing text is always XXXX

Hi,

Does the data follow any sort of pattern with regard to how many characters in length and where abouts in the string the section that needs replacing is?

Claus Busch

Replace data to right of string problem
 
Hi,

Am Sun, 25 Nov 2012 08:55:01 +0000 schrieb Jayjones:

Hi guys - trying to replace or substitute data to almost right of
string ie want excel to always count 5 characters from right of cell but
then only replace 4 of the characters with XXXX leaving last character
as it was eg 1234abcde becomes 1234XXXXe or 123456abcdesfgh becomes
123456abcdXXXXh. I have tried right function with replace but can't
manage to leave last digit intact. The replacing text is always XXXX


your string in A1:
=LEFT(A1,LEN(A1)-5)&REPT("X",4)&RIGHT(A1,1)


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2

Ron Rosenfeld[_2_]

Replace data to right of string problem
 
On Sun, 25 Nov 2012 08:55:01 +0000, Jayjones wrote:


Hi guys - trying to replace or substitute data to almost right of
string ie want excel to always count 5 characters from right of cell but
then only replace 4 of the characters with XXXX leaving last character
as it was eg 1234abcde becomes 1234XXXXe or 123456abcdesfgh becomes
123456abcdXXXXh. I have tried right function with replace but can't
manage to leave last digit intact. The replacing text is always XXXX


Also try:

=REPLACE(A1,LEN(A1)-4,4,"xxxx")


Kevin@Radstock

Hi Jayjones

Assuming your data is in A1:

=SUBSTITUTE(A1,RIGHT(A1,5),"XXXX"&RIGHT(A1,1)) and copy down.

kevin


Quote:

Originally Posted by Jayjones (Post 1607610)
Hi guys - trying to replace or substitute data to almost right of string ie want excel to always count 5 characters from right of cell but then only replace 4 of the characters with XXXX leaving last character as it was eg 1234abcde becomes 1234XXXXe or 123456abcdesfgh becomes 123456abcdXXXXh. I have tried right function with replace but can't manage to leave last digit intact. The replacing text is always XXXX


Jayjones

Quote:

Originally Posted by Spencer101 (Post 1607611)
Hi,

Does the data follow any sort of pattern with regard to how many characters in length and where abouts in the string the section that needs replacing is?

The data can be various lengths but it's always the last 4 characters but one that needs to be replaced ie I want excel to count from right 5 characters then replace the next 4 characters leaving the 5 th character intact

Kevin@Radstock

Thats what I have just given you is'nt it !

Quote:

Originally Posted by Jayjones (Post 1607614)
The data can be various lengths but it's always the last 4 characters but one that needs to be replaced ie I want excel to count from right 5 characters then replace the next 4 characters leaving the 5 th character intact


Jayjones

Quote:

Originally Posted by Kevin@Radstock (Post 1607613)
Hi Jayjones

Assuming your data is in A1:

=SUBSTITUTE(A1,RIGHT(A1,5),"XXXX"&RIGHT(A1,1)) and copy down.

kevin

Hi Kevin, thank you so much - wouldn't have thought about combination. Wish I had posted this sooner!

Kevin@Radstock

No problem, glad your sorted.

Quote:

Originally Posted by Jayjones (Post 1607616)
Hi Kevin, thank you so much - wouldn't have thought about combination. Wish I had posted this sooner!


Jayjones

Quote:

Originally Posted by Kevin@Radstock (Post 1607615)
Thats what I have just given you is'nt it !

Sorry Kevin I responded to last message before seeing yours - still new to these kinds of sites - again really appreciate your solution:) - saved me so much time!

Claus Busch

Replace data to right of string problem
 
Hi,

you can also try:
=SUBSTITUTE(A1,MID(A1,LEN(A1)-4,4),"XXXX")


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2


All times are GMT +1. The time now is 02:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com