Hello All,
I work at a test lab and i have over 500,000 test records. I need to remove the duplicate record rows. The file has this layout. A patient can have multiple test and on rare cases have a different case number.
[TABLE="width: 500"]
<tbody>[TR]
[TD]Case Number[/TD]
[TD]Patient Name[/TD]
[TD]Test[/TD]
[TD]Patient ID[/TD]
[/TR]
[TR]
[TD]1011[/TD]
[TD]John Smith[/TD]
[TD]ABC123[/TD]
[TD]5555[/TD]
[/TR]
[TR]
[TD]1011[/TD]
[TD]John Smith[/TD]
[TD]ABC123[/TD]
[TD]5555
[/TD]
[/TR]
[TR]
[TD]1014[/TD]
[TD]Jane Doe[/TD]
[TD]YHF162[/TD]
[TD]5512[/TD]
[/TR]
[TR]
[TD]1014[/TD]
[TD]Jane Doe[/TD]
[TD]BRAC21[/TD]
[TD]5512[/TD]
[/TR]
[TR]
[TD]1032[/TD]
[TD]Jane Doe[/TD]
[TD]JFEH12[/TD]
[TD]5512[/TD]
[/TR]
[TR]
[TD]1014[/TD]
[TD]Jane Doe[/TD]
[TD]YHF162[/TD]
[TD]5512[/TD]
[/TR]
[TR]
[TD]1014[/TD]
[TD]Jane Doe[/TD]
[TD]BRAC21[/TD]
[TD]5512[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Case Number[/TD]
[TD]Patient Name[/TD]
[TD]Test[/TD]
[TD]Patient ID[/TD]
[/TR]
[TR]
[TD]1011[/TD]
[TD]John Smith[/TD]
[TD]ABC123[/TD]
[TD]5555[/TD]
[/TR]
[TR]
[TD]1014[/TD]
[TD]Jane Doe[/TD]
[TD]YHF162[/TD]
[TD]5512[/TD]
[/TR]
[TR]
[TD]1014[/TD]
[TD]Jane Doe[/TD]
[TD]BRAC32[/TD]
[TD]5512[/TD]
[/TR]
[TR]
[TD]1032[/TD]
[TD]Jane Doe[/TD]
[TD]JFEH12[/TD]
[TD]5512[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I want to create a macro that will give me this result.
I have the following.
This code only gives me the following records.
[TABLE="width: 500"]
<tbody>[TR]
[TD]1011[/TD]
[TD]John Smith[/TD]
[TD]ABC123[/TD]
[TD]5555[/TD]
[/TR]
[TR]
[TD]1011[/TD]
[TD]John Smith[/TD]
[TD]ABC123[/TD]
[TD]5555[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 500"]
<tbody>[TR]
[TD]1014[/TD]
[TD]Jane Doe[/TD]
[TD]YHF162[/TD]
[TD]5512[/TD]
[/TR]
</tbody>[/TABLE]
Thanks in advance.
I work at a test lab and i have over 500,000 test records. I need to remove the duplicate record rows. The file has this layout. A patient can have multiple test and on rare cases have a different case number.
[TABLE="width: 500"]
<tbody>[TR]
[TD]Case Number[/TD]
[TD]Patient Name[/TD]
[TD]Test[/TD]
[TD]Patient ID[/TD]
[/TR]
[TR]
[TD]1011[/TD]
[TD]John Smith[/TD]
[TD]ABC123[/TD]
[TD]5555[/TD]
[/TR]
[TR]
[TD]1011[/TD]
[TD]John Smith[/TD]
[TD]ABC123[/TD]
[TD]5555
[/TD]
[/TR]
[TR]
[TD]1014[/TD]
[TD]Jane Doe[/TD]
[TD]YHF162[/TD]
[TD]5512[/TD]
[/TR]
[TR]
[TD]1014[/TD]
[TD]Jane Doe[/TD]
[TD]BRAC21[/TD]
[TD]5512[/TD]
[/TR]
[TR]
[TD]1032[/TD]
[TD]Jane Doe[/TD]
[TD]JFEH12[/TD]
[TD]5512[/TD]
[/TR]
[TR]
[TD]1014[/TD]
[TD]Jane Doe[/TD]
[TD]YHF162[/TD]
[TD]5512[/TD]
[/TR]
[TR]
[TD]1014[/TD]
[TD]Jane Doe[/TD]
[TD]BRAC21[/TD]
[TD]5512[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Case Number[/TD]
[TD]Patient Name[/TD]
[TD]Test[/TD]
[TD]Patient ID[/TD]
[/TR]
[TR]
[TD]1011[/TD]
[TD]John Smith[/TD]
[TD]ABC123[/TD]
[TD]5555[/TD]
[/TR]
[TR]
[TD]1014[/TD]
[TD]Jane Doe[/TD]
[TD]YHF162[/TD]
[TD]5512[/TD]
[/TR]
[TR]
[TD]1014[/TD]
[TD]Jane Doe[/TD]
[TD]BRAC32[/TD]
[TD]5512[/TD]
[/TR]
[TR]
[TD]1032[/TD]
[TD]Jane Doe[/TD]
[TD]JFEH12[/TD]
[TD]5512[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I want to create a macro that will give me this result.
I have the following.
Code:
Sub SameLine ()
Dim x as long
Dim y as long
Dim Test as long
test = cells.find (what:="Test", LookIn =:xlformulas, lookAt:=xlPart, searchOrder=:xLByRow, SearchDirection:=XlNext, MatchCase:=false_, SearchFormat=:false).column
Dim VarStart as Long
varstart = cells.find (what:="Case Number", LookIn =:xlformulas, lookAt:=xlPart, searchOrder=:xLByRow, SearchDirection:=XlNext, MatchCase:=false_, SearchFormat=:false).column
dim varend as long
varend = 0
do while cells (x,1).value <> ""
y=y +varend +2
rows(x+1).delete
x=x+1
loop
end sub
This code only gives me the following records.
[TABLE="width: 500"]
<tbody>[TR]
[TD]1011[/TD]
[TD]John Smith[/TD]
[TD]ABC123[/TD]
[TD]5555[/TD]
[/TR]
[TR]
[TD]1011[/TD]
[TD]John Smith[/TD]
[TD]ABC123[/TD]
[TD]5555[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 500"]
<tbody>[TR]
[TD]1014[/TD]
[TD]Jane Doe[/TD]
[TD]YHF162[/TD]
[TD]5512[/TD]
[/TR]
</tbody>[/TABLE]
Thanks in advance.