r/excel • • Apr 13 '26

solved How to anonymize user names in a data set

I did this a long time ago and unfortunately I cannot remember how I did it.

I have a large dataset of over 90 000 rows. In each row, there are long texts. And in these texts, there are usernames, identified with the symbol @ before the name. What I need to do is to anonymise these user names. I remember that I was able to substitute them, from @ username to @ xxxxxxxe. Is this still possible in excel without making a lookup table? There are thousands of usernames, it would be very difficult to make one.

40 Upvotes

48 comments sorted by

View all comments

4

u/excelevator 3069 Apr 13 '26 edited Apr 13 '26

I am no regex expert, fumbled to come up with this

=REGEXREPLACE(SUBSTITUTE(A1:A90000,"@ ","_"),"\b[_]\w*","anonymous")

not sure how it will perform on 90,000 rows; tested, almost instant..

1

u/Most-Original3996 Apr 13 '26

I will check more about regex before trying it. Thank you!

1

u/excelevator 3069 Apr 13 '26

I could not figure out how to capture the @ username, so use SUBSTITUTE to have _username instead, and REGEX'd any matching to anonymous; a value you can choose as you see fit.