Stop Code instead of trying to copy and Paste

WireGuy8

New Member
Joined
Feb 7, 2022
Messages
18
I have this filter set up for project. It is filtering data in column D from data on reference cell Q1. This works really well and I can use this to copy the data and paste it in another cell. The problem comes when Q1 is blank, the filter hides everything, which is good, but I do not need to copy blank rows. How can I have this stop if Q1 is blank and not copy anything. Just move on to the next set of coading

sheet10.Activate
With Range("Q1")
If .Value = "" Then
Range("D3").AutoFilter 4, "", xlAnd, "<>"
Else
Range("D3").AutoFilter 4, "*" & .Value & "*"
End If
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
sheet10.Activate
With Range("Q1")
If .Value = "" Then
Range("D3").AutoFilter 4, "", xlAnd, "<>"
Else
Range("D3").AutoFilter 4, "*" & .Value & "*"
End If

If .Columns(4).SpecialCells(xlVisible).Rows.Count = 1 Then Exit Sub
.AutoFilter.Range.Offset(1).Columns("D").Copy
sheet3.Range("K44").PasteSpecial xlPasteValues
.AutoFilter.Range.Offset(1).Columns("L").Copy
sheet3.Range("L44").PasteSpecial xlPasteValues

End With
 
Upvote 0

Forum statistics

Threads
1,215,521
Messages
6,125,307
Members
449,218
Latest member
Excel Master

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