ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If filter results in blank cells, skip to next part of program (https://www.excelbanter.com/excel-programming/413473-if-filter-results-blank-cells-skip-next-part-program.html)

stevec

If filter results in blank cells, skip to next part of program
 
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...



DMoney

If filter results in blank cells, skip to next part of program
 
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:




"SteveC" wrote:

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...



stevec

If filter results in blank cells, skip to next part of program
 
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?


"dmoney" wrote:

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:




"SteveC" wrote:

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...




All times are GMT +1. The time now is 06:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com