VBA to Find Duplicate Row & Clear Contents of Cell in Column

LA_256

New Member
Joined
Jun 1, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
It's been 10 years since I was in VBA and I'm very rusty so any assistance on my current project is greatly appreciated. We are trying to do an invoice upload to our system instead of manually enter every invoice.
I've written the vba to take data from one sheet to a new sheet with no issue including duplicating rows that have values in column M. Where I'm stuck is I need to locate those duplicate rows and clear the contents in contents that duplicate row so that it is no longer a duplicate.
Right now, it copies the data that has "Ready to Invoice", has not been sent (No "Yes" in Column W), and is not waiting for PO (Column S). Once it pulls that in, it goes back through and duplicates any rows that are not blank in Per Diem (Column M). The reason we duplicate is because the Per Diem will have to be a separate line on the invoice and our import process requires it to be a separate row in excel in order to do that.
If clearing the contents in Price of the duplicate row is not an option, then I need to have the duplicate row highlighted so I can manual update Price column for the duplicates.
The data can be sorted by Date, Billing, Site, and customer if it helps as that will have to happen before we upload.
Just an fyi.. the image only shows a few rows, but by December our billing tracker will be close to 20,000 rows. It grows by almost 5,000 rows a year.
 

Attachments

  • Import Invoice Sample.png
    Import Invoice Sample.png
    29.4 KB · Views: 17

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
It is challenging, for me at least, to provide assistance without having something to work with. Is it possible to post a workbook with real or at least realistic data. Use the link icon above the message area.
 
Upvote 0
It is challenging, for me at least, to provide assistance without having something to work with. Is it possible to post a workbook with real or at least realistic data. Use the link icon above the message area.
Sorry for the delay. Attached is the sample sheet.

Invoice Import Sample.xlsx
ABCDEFGHIJKLMNOPQRSTUVW
1DateStateFreq.BillingSiteCustomerLOCATIONTECHPDP Uploaded by TechReportPilesCheck InPRICEMMBillingProduct ServiceNotesJustPO#StatusInvoice #Invoice
25/11/2023OK116116-008Delta DivisionElkhartJHill5/14/2023 22:0015-May60$1,650.00SamplingStockWaiting
35/11/2023OK116116-008Delta DivisionElkhartJHill5/14/2023 22:0019-MayN/AFlightServices6300442983Tim Review
45/11/2023WA190190-001Company ABCSeattleJordan5/12/2023 6:0015-May33$150.00$2,000.00SamplingStock4501709543Ready to Invoice
55/11/2023OH116116-020Delta DivisionLexingtonDaniel5/12/2023 8:0023-MayN/AFlightServices
65/11/2023FL116116-018Delta DivisionOrlandoDaniel5/12/2023 8:0018-MayN/A$1,800.00FlightServices6300442902Ready to Invoice
75/11/2023IL116-000-000116-000-019Prairie MaterialsMcDowellDaniel5/12/2023 8:0017-May26$75.00$1,650.00SamplingStockWaiting
85/11/2023IL116116-019Prairie MaterialsMcDowellDaniel5/12/2023 8:0022-MayN/A$1,800.00FlightServices6300442935Ready to Invoice23244Yes
95/11/2023TXQ424424-001WC IndustriesDallasChase5/11/2023 20:0024-MayN/A$2,400.00FlightServicesN/AReady to Invoice
105/11/2023VAQ424424-002WC IndustriesHRRCPaul5/11/2023 12:0023-MayN/A$200$2,400.00FlightServicesN/AReady to Invoice23246Yes
11
125/12/2023TXQ106106-027ABC LLCAmarilloJackson5/12/2023 16:0024-MayN/A$2,800.00FlightServices30629917Ready to Invoice23247Yes
135/12/2023AR125125-008Xotic SystemFormanDarrell5/12/2023 20:0022-MayN/A$4,400.00FlightServices
145/12/2023IL208208-002TMSMantenoDaniel5/12/2023 22:0016-May2$1,950.00SamplingStock
Billing Tracker
 
Upvote 0
I've written the vba to take data from one sheet to a new sheet with no issue including duplicating rows that have values in column M.

So your code duplicates rows with Per Diem value in Column M. And then the first row has just price and the second row has the Per Diem?

Where I'm stuck is I need to locate those duplicate rows and clear the contents in contents that duplicate row so that it is no longer a duplicate.

This is confusing to me. You need to locate the duplicate rows and clear some data in the duplicate (second) row so "it is no longer a duplicate"?

Right now, it copies the data that has "Ready to Invoice", has not been sent (No "Yes" in Column W), and is not waiting for PO (Column S).

So your code copies data whose 1. value in the "Status" column (column U) is "Ready to Invoice", 2. value in "Invoice" column (column W) in not "Yes" and 3. value in "Just" column (column S) in not "Waiting"?

Once it pulls that in, it goes back through and duplicates any rows that are not blank in Per Diem (Column M). The reason we duplicate is because the Per Diem will have to be a separate line on the invoice and our import process requires it to be a separate row in excel in order to do that.

I cannot tell, is "it" your code or code that you need? Whichever, you need a "duplicate row" where the above qualifications are met and for which there is a value for Per Diem (column M)?

If clearing the contents in Price of the duplicate row is not an option, then I need to have the duplicate row highlighted so I can manual update Price column for the duplicates.

Why can contents of "Price" column (column N) not be clearable?

The data can be sorted by Date, Billing, Site, and customer if it helps as that will have to happen before we upload.

Of course code can do this.

Just an fyi.. the image only shows a few rows, but by December our billing tracker will be close to 20,000 rows. It grows by almost 5,000 rows a year.

Is the data that you posted enough to develop and test code? If there is not more than one or two instances of the circumstances that need processing then you'll need to provide more.
 
Upvote 0

Forum statistics

Threads
1,214,628
Messages
6,120,618
Members
448,973
Latest member
ChristineC

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top