If filter results in blank cells, skip to next part of program

S

SteveC

I have a macro that runs a filter, copies the results, and pastes it into
another worksheet.

How do I skip to next part of code if the filter results are blank? For
some reason, Excel 2007 crashes when it tries to copy and paste blank filter
results.


This is part of the code that I have now:

Sheets("Screens").Select
Range("B9:FA9").Select
Selection.Copy

Sheets("List").Select
Range("AI6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Application.Run "ShowAll"
Application.Run "Run_All_Filters"

Range("D13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Selector").Select
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

How do I modify this so if D13 is blank and there is nothing to select, it
will skip on to the next part of the code?

Thanks...
 
D

dmoney

Range("D13").Select
if activecell.value="" then goto skip
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Selector").Select
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
skip:
 
S

SteveC

Thanks for your help.

Didn't work though. This might be because the filter is applied to rows
13:6000.

If nothing passes the filter, the filter hides rows 13:6000, and the entire
column from row 13 to row 1048576 is selected (I can see rows 1:12 and rows
6001 on, rows 13:6000 are hidden). So I'm guessing you have to change
activecell to activerange or something?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top