LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
AutoRun Macro with a delay to give user the choice to cancel the macro wanderlust Excel Programming 2 September 28th 07 04:09 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor [email protected] Excel Programming 2 March 30th 07 07:48 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 05:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"