+ Reply to Thread
Results 1 to 7 of 7

VBA to extract rows that contain blank cells in specific columns

  1. #1
    Valued Forum Contributor
    Join Date
    09-09-2009
    Location
    Liverpool, England
    MS-Off Ver
    W: 2021 H: 365
    Posts
    940

    VBA to extract rows that contain blank cells in specific columns

    Afternoon all,

    I'm undertaking some data validation and I'd like to extract rows where any mandatory fields haven't been populated. I've attached an example of the data I'm working with. The mandatory columns are highlighted in green and I'd like the rows that don't meet the criteria to be copied on to a separate tab (with the header at the top).

    Thanks in advance,

    Snook
    Last edited by The_Snook; 09-13-2016 at 06:11 AM.

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: VBA to extract rows that contain blank cells in specific columns

    Hi Snook,
    something like this maybe
    Please Login or Register  to view this content.

  3. #3
    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

    Re: VBA to extract rows that contain blank cells in specific columns

    Hi,

    This is clearly a much simplified example and probably doesn't represent the size of your actual data. We often find that when we give an answer to what is a trivial non representative example when the solution is used with the real world data it doesn't work because of factors like string length and other stuff which is important but hasn't been mentioned.

    That said does the attached help. If npt make sure you do upload your production workbook, or at least a cut down representative copy.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Valued Forum Contributor
    Join Date
    09-09-2009
    Location
    Liverpool, England
    MS-Off Ver
    W: 2021 H: 365
    Posts
    940

    Re: VBA to extract rows that contain blank cells in specific columns

    Hi Richard,

    Thanks for this it looks just the job. I've been reading up on advanced filters but I'm still struggling to understand why your criteria range works? I'd be grateful if you could provide a brief explanation of how and why it works.

    Re the example data, you're correct. I'm waiting on someone to return from leave before I can obtain an actual copy of the data I'll be working with. I have a good idea of the checks I'll be required to undertake so I'm trying to get ahead of the game.

    nilem - Thanks for your solution as well which worked a treat.

    Snook

  5. #5
    Valued Forum Contributor
    Join Date
    09-09-2009
    Location
    Liverpool, England
    MS-Off Ver
    W: 2021 H: 365
    Posts
    940

    Re: VBA to extract rows that contain blank cells in specific columns

    Also, would advanced filtering be suitable if I have multiple criteria? For example, in addition to undertaking the blank check I know there's going to be a mileage field where I need to ensure that the value input isn't 0.

  6. #6
    Valued Forum Contributor
    Join Date
    09-09-2009
    Location
    Liverpool, England
    MS-Off Ver
    W: 2021 H: 365
    Posts
    940

    Re: VBA to extract rows that contain blank cells in specific columns

    I've been playing with the data and hammering the trial and error and I think (hope!) I've got my head around it now.

    Cheers,

    Snook

  7. #7
    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

    Re: VBA to extract rows that contain blank cells in specific columns

    Quote Originally Posted by The_Snook View Post
    Hi Richard,

    Thanks for this it looks just the job. I've been reading up on advanced filters but I'm still struggling to understand why your criteria range works? I'd be grateful if you could provide a brief explanation of how and why it works.


    Snook
    Hi,

    The requirement is to extract all rows where there is a blank in ANY of the columns. This is an OR condition. i.e. each column is mutually exclusive and independent of whatever is in any other column.
    To extract cells from every column the criteria range must have each criteria on its row.

    If all the criteria are on the same row this is an AND condition and means get the rows where there is a blank in every column ON THE SAME DATA ROW

    So the criteria uses the '=' sign which effectively means equals blank, and says
    extract blank rows where Test Data C is blank,
    OR where Test Data D is blank
    OR where Test Data G is blank
    ...etc

+ 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] Fill Blank Cells in Columns with Specified Header with a Specific Date
    By uberathlete in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-26-2014, 10:43 PM
  2. [SOLVED] VBA Delete Rows If All Specific Columns Are Blank
    By hobbiton73 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-03-2014, 04:50 AM
  3. Delete any blank rows from specific columns
    By tantcu in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-23-2013, 03:45 PM
  4. Replies: 3
    Last Post: 02-20-2013, 08:54 PM
  5. [SOLVED] Extract unique strings from excel cells across rows and columns
    By quedan in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 01-28-2013, 02:42 PM
  6. Replies: 2
    Last Post: 02-06-2012, 05:16 PM
  7. [SOLVED] extract data from a range of cells in rows or columns when a date.
    By Dartyon in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-24-2005, 07:06 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