+ Reply to Thread
Results 1 to 9 of 9

Deleting a row within a named worksheet if cell = No

  1. #1
    Registered User
    Join Date
    12-20-2015
    Location
    Uk
    MS-Off Ver
    2010
    Posts
    10

    Deleting a row within a named worksheet if cell = No

    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

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: Deleting a row within a named worksheet if cell = No

    Please Login or Register  to view this content.
    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.
    Last edited by jolivanes; 02-25-2017 at 11:57 PM.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Deleting a row within a named worksheet if cell = No

    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.

  4. #4
    Registered User
    Join Date
    12-20-2015
    Location
    Uk
    MS-Off Ver
    2010
    Posts
    10

    Re: Deleting a row within a named worksheet if cell = No

    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.

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Deleting a row within a named worksheet if cell = No

    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.

  6. #6
    Registered User
    Join Date
    12-20-2015
    Location
    Uk
    MS-Off Ver
    2010
    Posts
    10

    Re: Deleting a row within a named worksheet if cell = No

    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

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Deleting a row within a named worksheet if cell = No

    This will filter rows if column W is Blank and
    column V is Yes or NOA Started.

    Please Login or Register  to view this content.
    Again, you could record a macro and set the autofilters the way you want them to get the example code.

  8. #8
    Registered User
    Join Date
    12-20-2015
    Location
    Uk
    MS-Off Ver
    2010
    Posts
    10

    Re: Deleting a row within a named worksheet if cell = No

    Thanks again Alphafrog.

  9. #9
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Deleting a row within a named worksheet if cell = No

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Deleting a row on one worksheet based on a cell value in a different sheet
    By misfitmedico in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-23-2015, 10:13 AM
  2. Save each worksheet as .pdf named after cell value within worksheet
    By jbryant2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-01-2014, 02:10 AM
  3. Deleting value from 1st cell effects named range
    By tanvi_kalra in forum Excel General
    Replies: 2
    Last Post: 03-26-2014, 03:22 AM
  4. How to read a named cell from another worksheet
    By fraz627 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-27-2014, 03:33 PM
  5. Worksheet named as dynamic cell
    By Robert E Lee in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-04-2013, 09:16 AM
  6. [SOLVED] If cell = X then copy entire row to new worksheet named X
    By DanielJHB in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-21-2013, 05:40 PM
  7. Selecting and deleting named range based on cell value
    By Rich Kniatt in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-06-2006, 03:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1