ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Script/function to extract duplicate entries between two columns? (https://www.excelbanter.com/excel-programming/289311-script-function-extract-duplicate-entries-between-two-columns.html)

Jim Witte

Script/function to extract duplicate entries between two columns?
 
I have a spreadsheet set up like this

<username1 <real name2 <username2 <real name2
..

I want a way to extract all lines in series <username1 that are
somewhere in <username2 or, converly, are NOT in that series. Actually,
I want to extract both <username1 and <real name1 as one datum, but
that shouldn't be hard.

Is there a thouroughly easy way to do this with a macro (meaning under
4 lines), or should I just import that data into Runtime Revolution,
where I can write a 4 line script to do it.. (but the formating of the
data would take longer..)

Jim

Tom Ogilvy

Script/function to extract duplicate entries between two columns?
 
set cell = Range("A2")
do while not isempty(cell)
res = Application.Match(cell,Columns(3),0)
if not iserror(res) then
cell.Resize(1,2),Copy Destination:=Cells(rows.count,5).end(xlup)(2)
End if
Set cell = cell.offset(1,0)
Loop

remove the "not" to copy non-matches.

or in D2

=if(Countif(C:C,A2)0,A2,"")

and drag fill down the column.

--
Regards,
Tom Ogilvy


Jim Witte wrote in message
...
I have a spreadsheet set up like this

<username1 <real name2 <username2 <real name2
..

I want a way to extract all lines in series <username1 that are
somewhere in <username2 or, converly, are NOT in that series. Actually,
I want to extract both <username1 and <real name1 as one datum, but
that shouldn't be hard.

Is there a thouroughly easy way to do this with a macro (meaning under
4 lines), or should I just import that data into Runtime Revolution,
where I can write a 4 line script to do it.. (but the formating of the
data would take longer..)

Jim





All times are GMT +1. The time now is 11:42 PM.

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