Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
A little Macro Help Please ...
Ahh... good. Sorry... I wasn't sure what you meant; perhaps I didn't read
carefully enough the first time.. sorry. Anyway, here, this will do what you need. '*********** Selection.AutoFilter Field:=1, Criteria1:="<32*", Operator:=xlAnd Range("A3:N2000").Select If Range("a3:N2000").SpecialCells(xlCellTypeVisible). Count < Range("a3:N2000").Cells.Count Then Selection.ClearContents End If '************ The special cells xlcelltypevisible bit will check if the autofilter has hidden any rows, or not, and only run the clearcontents if the two counts (total cells vs. visible cells) don't match. "Ken" wrote: What I wish: 1: Criteria found ... Clear visible cells in Range A3:N2000. 2: Criteria not found ...Move on without clearing anything. As it is: 1: Criteria found ... Clears visible cells in Range A3:N2000. 2: Criteria not found ... Clears EVERYTHING in Range A3:N2000. Thanks ... Kha "mark" wrote: your code is set to clear everything left visible in the range A3:N2000 after the application of the AutoFilter. what do you want it to do? You didn't actually say. If you want it to apply the filter, but not delete anything, then just take out the two line: Selection.ClearContents "Ken" wrote: Excel2003 ... I know nothing of VB Code ... I record Macros only & then perform a little creative cut/paste as needed ... That said ... I have the following recorded Macro instruction: Range("A2").Select Selection.AutoFilter Field:=1, Criteria1:="<32*", Operator:=xlAnd Range("A3:N2000").Select Selection.ClearContents Issue is ... ALL Data is cleared from the Range ("A3:N2000") when the Criteria1:="<32*" is NOT found. When Criteria1 is found ... no problem. When Criteria1 is not found ... it sucks to be me. My Thanks to those that support these boards ... Kha |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
AutoRun Macro with a delay to give user the choice to cancel the macro | Excel Programming | |||
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort | Excel Worksheet Functions | |||
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor | Excel Programming | |||
how to count/sum by function/macro to get the number of record to do copy/paste in macro | Excel Programming | |||
Start Macro / Stop Macro / Restart Macro | Excel Programming |