Criteria1:="="

L

Legacy 198477

Guest
I am trying to filter out rows where specific column data is blank. When I run the code below and there are no rows with blank data, the entire worksheet is copied. If I do have one row with blank data in the column, only that row is copied. I need to script for all scenarios, so there will be times when I have rows with no blank columns. In this case, I do not want to copy anything. Help is greatly appreciated!

Sub NoInventoryDate()

Dim Rng As Range


With Sheets("Inventoried Items")
.AutoFilterMode = False
.Range("A1").AutoFilter field:=6, Criteria1:="="
Set Rng = .AutoFilter.Range
Set Rng = Rng.Offset(1).Resize(Rng.Rows.count - 1)
Rng.Copy Sheets("Missing").Cells(Rows.count, 1).End(xlUp)(2)
Rng.EntireRow.Delete
.AutoFilterMode = False
End With


End Sub
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
No. Unfortunately, this copies everything over as well. I am looking for blanks in a specific column in a row. If I find this, I want to copy the row to another worksheet. I'm finding that if none of my rows has blank data in this column, the Criteria1:="=" just copies everything over. If I have one row, for example that has blank data in the column, the Criteria1:="=" works for that one row. If not all the rows are copied.
 
Upvote 0
Maybe something like
(try it in a copy of your workbook)

Code:
Sub filterTest()
    Dim Rng As Range
 
    With Sheets("Inventoried Items")
 
        .AutoFilterMode = False
        .Range("A1").AutoFilter field:=6, Criteria1:="="
 
        On Error Resume Next
        Set Rng = .AutoFilter.Range.Offset(1). _
            Resize(.AutoFilter.Range.Rows.Count - 1). _
            SpecialCells(xlCellTypeVisible)
 
        If Not Rng Is Nothing Then
            Rng.Copy Sheets("Missing").Cells(Rows.Count, 1) _
            .End(xlUp)(2)
            Rng.EntireRow.Delete
        End If
 
        .AutoFilterMode = False
 
    End With
End Sub

M.
 
Upvote 0

Forum statistics

Threads
1,223,098
Messages
6,170,100
Members
452,301
Latest member
QualityAssurance

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