I am trying to delete a row within a named worksheet if the value in column W = No.
I have looked at various examples on this forum but cant adapt to make it work. Would any of the members have some code that would help.
Thanks
I am trying to delete a row within a named worksheet if the value in column W = No.
I have looked at various examples on this forum but cant adapt to make it work. Would any of the members have some code that would help.
Thanks
BTW, if with your question you mean that you want the code to work on a sheet other then the active sheet, you might want to try this.Please Login or Register to view this content.
If you have a large range, autofilter would be considerable faster.Please Login or Register to view this content.
Last edited by jolivanes; 02-25-2017 at 11:57 PM.
Change the sheet name to suit.
Please Login or Register to view this content.
Surround your VBA code with CODE tags e.g.;
[CODE]your VBA code here[/CODE]
The # button in the forum editor will apply CODE tags around your selected text.
Thanks Alphafrog for the response
I've changed my plan to filter if the cell in column W =" " and column v = "Yes"
The code I've used is below. Can you shed any light as to why if fails on line 3
Application.ScreenUpdating = False
With Sheets("Sheet1").UsedRange
.AutoFilter Field:=23, Criterial:=" "
.AutoFilter Field:=22, Criterial:="Yes"
.Offset(1).SpecialCells(xlCellTypeVisible).EntireRow.Delete
.Parent.AutoFilterMode = False
End With
Application.ScreenUpdating = True
Thanks for any help you can give.
The argument label should be Criteria1 (one) and not CriteriaL
Also, this criteria =" " will filter for a space character. If you want to filter for blank cells it would be ="="
You can get example code by recording a macro and setting the autofilter.
Last edited by AlphaFrog; 02-26-2017 at 02:34 PM.
Thanks again for your help.
I'm trying to base the delete row on multiple criteria but it will not delete any rows. The code is below. Any chance you could point me in the right direction. I'm guessing it doesn't like the multiple filter on column 22.
Application.ScreenUpdating = False
With Sheets("Prior Absence").UsedRange
.AutoFilter Field:=23, Criteria1:="="
.AutoFilter Field:=22, Criteria1:="Yes"
.AutoFilter Field:=22, Criteria1:="NOA Started"
.Offset(1).SpecialCells(xlCellTypeVisible).EntireRow.Delete
.Parent.AutoFilterMode = False
End With
Application.ScreenUpdating = True
Thanks again
This will filter rows if column W is Blank and
column V is Yes or NOA Started.
Again, you could record a macro and set the autofilters the way you want them to get the example code.Please Login or Register to view this content.
Thanks again Alphafrog.
You're welcome.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks