Erasing cells in a filtered database

NewOrderFac33

Well-known Member
Joined
Sep 26, 2011
Messages
1,283
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
Good afternoon,

I am filtering an Excel database on column A, within a For Each loop using a list of unique Column A items located on another worksheet.
This all works fine and results in one or more rows being displayed for each item.
Column AB always contains the same value for each filtered set and I now need (providing that the filter returns more than one row) to erase all the values from Column AB, apart from the one in the first displayed row. So, if the filter displayed rows 12, 24, 45 and 67, I would need to erase the value in AB24, AB45 and AB67, leaving the value in AB12 in place.

If the filter returned ONLY one row (for example 18), the value in AB18 would need to remain in place.

I think I need to select an offset of 1 row from the first filtered value in column AB (to retain the first value), then erase the remaining values, but I can't find an easy way to select just the visible rows within the filter whilst making sure I exclude the first value.

Can anyone help, please?

As always, thanks in advance
Pete
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Sorted (if a little messy)
Code:
'If more than one row is displayed by the filter, erase all the value in 
        'column AB, apart from the one in the first displayed row.
        If FilterCount > 1 Then
            InputSheet.Range("Col_DB_IssueOriginalEstimate").SpecialCells(xlCellTypeVisible).Select
            'Store the AB column value from the first displayed row.
            RetainValue = Selection.Cells(1).Value
            MsgBox (Selection.Address & Chr(10) & "Retain Value: " & RetainValue)
            For Each MyCell3 In Selection
                MyCell3.ClearContents
            Next
            Selection.Cells(1) = RetainValue
            MsgBox ("Pause")
        End If
Thanks to those who gave it any consideration
Pete
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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