Deleting only some data in rows

stylencia18

New Member
Joined
Aug 14, 2017
Messages
31
Good afternoon:


I have 180,000 rows in Excelof bid numbers and award amounts. The problem is the award amounts repeat inevery row. How do I only keep the first award amount and delete the duplicateaward amounts without deleting the entire row.


Bid Number Award Amount
1 $500
1 $500 (delete this amount but keep the rest ofthe data in this row)
1 $500 (delete this amount but keep the rest ofthe data in this row)
1 $500 (delete this amount but keep the rest ofthe data in this row)
1 $500 (delete this amount but keep the rest ofthe data in this row)
2 $700
2 $700 (delete this amount but keep the rest ofthe data in this row)

2 $700 (delete this amount but keep the rest ofthe data in this row)
2 $700 (delete this amount but keep the rest ofthe data in this row)
2 $700 (delete this amount but keep the rest ofthe data in this row)
3 $900
3 $900 (deletethis amount but keep the rest of the data in this row)
3 $900 (delete this amount but keep the rest ofthe data in this row)
3 $900 (delete this amount but keep the rest ofthe data in this row)

 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
So, are they always sorted by Bid Number and Award Amount?
Is Bid Number in column A and Award Amount in column B?
On each duplicate row, do you just want to clear the Award Amount in column B, but leave Bid Number in column A?
Would you ever have an instance where you could have two different Award Amounts for a single Bid Number?
 
Upvote 0

  1. Yes,sorted by bid number and amount
  2. BidNumber is Column A, Award Amount is Column W

  3. Yes,just clear the award amount. leave Bid number in Column A and all other data in the row

  4. Each bidnumber has the same award amount
 
Upvote 0
Because of this:
Yes,sorted by bid number and amount
and this:
Each bidnumber has the same award amount
This should work:
Code:
Sub ClearAmounts()

    Dim lr As Long, r As Long
    
    Application.ScreenUpdating = False
    
'   Find last row in column A with numbers
    lr = Cells(Rows.Count, "A").End(xlUp).Row
    
'   Loop through all rows in column A, starting on row 2
    For r = 2 To lr
'       If value in column A the same as the row above, clear column W
        If Cells(r, "A") = Cells(r - 1, "A") Then Cells(r, "W").ClearContents
    Next r
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0
WOW it worked!!!! THANK YOU!!!








Because of this:

and this:

This should work:
Code:
Sub ClearAmounts()

    Dim lr As Long, r As Long
    
    Application.ScreenUpdating = False
    
'   Find last row in column A with numbers
    lr = Cells(Rows.Count, "A").End(xlUp).Row
    
'   Loop through all rows in column A, starting on row 2
    For r = 2 To lr
'       If value in column A the same as the row above, clear column W
        If Cells(r, "A") = Cells(r - 1, "A") Then Cells(r, "W").ClearContents
    Next r
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0
You are welcome.
Glad I was able to help!
:)
 
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