ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Writing VBA Code to compare lines of the same invoice. (https://www.excelbanter.com/excel-programming/419089-writing-vba-code-compare-lines-same-invoice.html)

yoshimarine

Writing VBA Code to compare lines of the same invoice.
 
I am trying to write a macro to clean up a spreadsheet of data. I am to a
point where I need to delete multiple rows that have the same invoice number
that don't meet certain criteria. Right now the macro will delete all lines
that have a subCount of 1, this removes all single line entries for that
specific invoice. Then it will remove all debit amounts with a deduction
code greater than 1 (these are deduction paybacks. Now I need to remove all
credit amounts that have a different date than the original payment as these
are deductions made against the same invoice again, but at a later date. My
question is, is there a way to do a loop that will compare a select group of
lines (lines with the same invoice number) and either delete all of them, or
just a select few?

Thank You,

Per Jessen[_3_]

Writing VBA Code to compare lines of the same invoice.
 
HI

Set TargetDate equal to the desired date and try this loop:

For Each cell In Selection
If cell.Value < TargetDate Then
cell.EntireRow.Delete
End If
Next

Regards,
Per

"yoshimarine" wrote:

I am trying to write a macro to clean up a spreadsheet of data. I am to a
point where I need to delete multiple rows that have the same invoice number
that don't meet certain criteria. Right now the macro will delete all lines
that have a subCount of 1, this removes all single line entries for that
specific invoice. Then it will remove all debit amounts with a deduction
code greater than 1 (these are deduction paybacks. Now I need to remove all
credit amounts that have a different date than the original payment as these
are deductions made against the same invoice again, but at a later date. My
question is, is there a way to do a loop that will compare a select group of
lines (lines with the same invoice number) and either delete all of them, or
just a select few?

Thank You,



All times are GMT +1. The time now is 11:13 AM.

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