ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   De-identify data (https://www.excelbanter.com/excel-worksheet-functions/188143-de-identify-data.html)

Eilean

De-identify data
 
Hello,

I'm new to this group

I've got a "student names" column (about 3000 names) and a "student
comments" column (about 23,000 comments). I would like to replace all names
appearing in "student comments" entries with an X by matching with entries in
"student names" column.

Is there a way of automating this with an Excel function? I'm using Excel
2007 and am a "basic" Excel user.

Thanks in advance

Gary''s Student

De-identify data
 
Let's assume that the names are in column A and the comments are in column B.
Enter and run this small macro:

Sub Macro2()
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
v = Cells(i, "A").Value
Columns("B:B").Replace What:=v, Replacement:="X", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next
End Sub

Data that starts out looking like:

John Smith John Smith is nice.
Mary Mary is good
James James is better
Larry
Moe
Curley

will become:

John Smith X is nice.
Mary X is good
James X is better
Larry
Moe
Curley


Macros are very easy to install and use:

1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE window as above
2. clear the code out
3. close the VBE window

To use the macro from Excel:

1. ALT-F8
2. Select the macro
3. Touch RUN

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

--
Gary''s Student - gsnu200787


"Eilean" wrote:

Hello,

I'm new to this group

I've got a "student names" column (about 3000 names) and a "student
comments" column (about 23,000 comments). I would like to replace all names
appearing in "student comments" entries with an X by matching with entries in
"student names" column.

Is there a way of automating this with an Excel function? I'm using Excel
2007 and am a "basic" Excel user.

Thanks in advance


Eilean

De-identify data
 
Thank you very, very much!! Exactly what I was after!

All the best,

Eilean


"Gary''s Student" wrote:

Let's assume that the names are in column A and the comments are in column B.
Enter and run this small macro:

Sub Macro2()
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
v = Cells(i, "A").Value
Columns("B:B").Replace What:=v, Replacement:="X", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next
End Sub

Data that starts out looking like:

John Smith John Smith is nice.
Mary Mary is good
James James is better
Larry
Moe
Curley

will become:

John Smith X is nice.
Mary X is good
James X is better
Larry
Moe
Curley


Macros are very easy to install and use:

1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE window as above
2. clear the code out
3. close the VBE window

To use the macro from Excel:

1. ALT-F8
2. Select the macro
3. Touch RUN

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

--
Gary''s Student - gsnu200787


"Eilean" wrote:

Hello,

I'm new to this group

I've got a "student names" column (about 3000 names) and a "student
comments" column (about 23,000 comments). I would like to replace all names
appearing in "student comments" entries with an X by matching with entries in
"student names" column.

Is there a way of automating this with an Excel function? I'm using Excel
2007 and am a "basic" Excel user.

Thanks in advance



All times are GMT +1. The time now is 03:12 PM.

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