De-identify data

  • Thread starter Thread starter Eilean
  • Start date Start date
E

Eilean

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top