monsefoster
New Member
- Joined
- Oct 29, 2013
- Messages
- 40
I'm trying to find a way to delete all BUT the repeated rows in a file, I know it's possible to delete the duplicates on a file in PHPExcel that would be done something like this:
However I need to do pretty much the opposite, delete all the rows that doesn't have any duplicates in the file.
I'd like to know how to accomplish this in VBA in order to give me an idea on what needs to be done and then trying to do it using this "library" called PHPExcel. I have some VBA knowledge however I can't seem the find the right approach.
**Why do I need this*: The duplicate rows are the intersection between M x M sets with data. It's way easier to do it directly on the file that having to considerate the M x M possible results.*
I'd greatly appreciate any guidance you might offer me.
Code:
<code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit;">
<code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit;">$worksheet = $objPHPExcel->getActiveSheet(); foreach ($worksheet->getRowIterator() as $row) { $rowIndex = $row->getRowIndex(); foreach ($worksheet->getRowIterator($rowIndex + 1) as $testRow) { if ($testRow == $row) { $worksheet->removeRow($rowIndex); } }</code></pre></code>
However I need to do pretty much the opposite, delete all the rows that doesn't have any duplicates in the file.
I'd like to know how to accomplish this in VBA in order to give me an idea on what needs to be done and then trying to do it using this "library" called PHPExcel. I have some VBA knowledge however I can't seem the find the right approach.
**Why do I need this*: The duplicate rows are the intersection between M x M sets with data. It's way easier to do it directly on the file that having to considerate the M x M possible results.*
I'd greatly appreciate any guidance you might offer me.