+ Reply to Thread
Results 1 to 8 of 8

Delete Row

  1. #1
    Forum Contributor
    Join Date
    12-04-2006
    Posts
    201

    Delete Row

    Hi,

    does anyone know a code that will search column 'I', and if '#N/A' is found, will delete the entire row and move everything up?

    thanks in advance

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    You don't necessarily need VBA code. You could just filter column I for the #N/A and then just select and delete all the filtered rows. If necessary do the same thing with a macro.

    HTH

  3. #3
    Forum Contributor
    Join Date
    12-04-2006
    Posts
    201
    Hi, thanks,

    unfortunatley on this occasion it does need to be VBA as its part of a much larger sheet...

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi,

    In that case just get VBA to undertake the filtering and deleting for you. I only said that you don't necessarily need VBA. VBA can do anything you can do manually.

    Rgds

  5. #5
    Forum Contributor
    Join Date
    12-04-2006
    Posts
    201
    Hi,

    i appreciate the input, but the rows need to be deleted...other sheets looks up into it...

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    But that's exactly what I'm suggesting.

    First have the macro do the filtering, then have it select the flltered rows, (or filtered cells if you don't want to delete the entire row), and delete them. Or am I missing something?

    As I said all you're asking the macro to do is something which you can do manually.

    Rgds

  7. #7
    Forum Contributor
    Join Date
    12-04-2006
    Posts
    201
    the amount of rows that need to be deleted will change week on week, so i can't record a macro to achieve this

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi,

    Who said anything about recording a macro?

    Your original post simply mentioned searching column I, which is what I was answering. The easiest way to 'search' a column for defined values is to filter it. Unless you don't want to delete some of the filtered #N/A values, then I fail to understand where the number of rows enters the equation. Either you want to find the #N/A cells or you don't. If you do, surely the 'amount of rows' is irrelevant.

    If therefore you're not talking about finding and deleting all the #N/A values my answer will be different.

    I didn't say anything about recording a macro. You've just identified one of the big deficiencies in a recorded macro. If there's a specific subset of column I that you want to filter, and somehow the numbers of rows are relevant, then the first thing you need to do is have the macro work out what those rows are. NOTE - you can't do this if you simply record a macro, but you can certainly get VBA to work it out.

    Then when you know this relevant range, just use the filtering and deleting I mentioned earlier.

    HTH

+ 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. How to delete rows in a protected worksheet
    By md95065 in forum Excel General
    Replies: 7
    Last Post: 12-19-2011, 07:27 PM
  2. Delete sheet warning - Excel 2007
    By ec41hw in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-29-2008, 03:10 PM
  3. conditional row delete and autofilter
    By Marcus Gee in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-03-2007, 12:34 AM
  4. Delete Data with code
    By rz6657 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-24-2007, 09:00 AM
  5. Auto delete row in this specific pattern
    By truongn2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-03-2007, 11:20 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