ClearContents behaving differently on two different computers.

dmprod192

New Member
Joined
Jul 10, 2013
Messages
2
Alright, I have two identical machines running this macro with the same input file. All reference libraries are consistent, but for some reason one system keeps bugging out on this section of code. It is intended to filter to blank cells containing only "-", select the filtered cells, and then clear the contents.

Both systems will highlight the filtered range, say AB5:AB100. When the ClearContents command is run on the first machine, it only clears the contents of the visible, filtered cells. On the second machine, all unfiltered cells in the range are also cleared. So after this command is run and the filter is turned off, One spreadsheet will still have values in AB10, AB20, AB30, etc. but the other spreadsheet will have this column totally blank.

I am wondering if this might be a system setting or something... Both machines are on Excel 2007. The version numbers vary slightly but I don't think that would matter. I am out of ideas why this is happening.

Thanks in advance for any input!


Code:
    ActiveSheet.Range("$A4").AutoFilter Field:=28, Criteria1:="-"
    Range("AB5").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.ClearContents
    ActiveSheet.ShowAllData
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
.
.

Change your ClearContents line to:

Selection.SpecialCells(xlCellTypeVisible).ClearContents

This way, only the visible cells will be cleared.
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,303
Members
449,078
Latest member
nonnakkong

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