+ Reply to Thread
Results 1 to 28 of 28

Find consecutive non blank cells in a column

  1. #1
    Registered User
    Join Date
    09-27-2012
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2010
    Posts
    85

    Find consecutive non blank cells in a column

    Hello , Maybe this is a simple questions but I am stumped at it.

    I have a column that has some cells populated with numbers but majority of cells are blank in that row.

    What I want to find is if there are any non blank cells that are next to each other? How can i find two consecutive non-blank cells within a range say for example (A1:A200) in the column? Can someone please give me some pointers?
    Last edited by desibabuji; 11-06-2013 at 05:04 AM.

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Find consecutive non blank cells in a column

    Hi,

    When you say you want to 'find' them, exactly what do you wish to have returned? The row numbers of each of these cells?

    What if there is more than one occurrence of a range of non-blank cells in your range? Do you want those returned as well, or just the first?

    Where do you want them returned?

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Find consecutive non blank cells in a column

    Please attach a sample workbook with enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

    Note: Please don't attach documents containing confidential data like (address, telephone, ID#s, etc.).


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  4. #4
    Registered User
    Join Date
    09-27-2012
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: Find consecutive non blank cells in a column

    Thanks for replying to the thread and apologies for not attaching a sample file. Please find attached a sample file attached with before and after tabs, this is a sample data from a rather large sheet with large number of rows.

    the BEFORE Sheet has some names and then the total associated with the individuals. Every total should have at least one "blank cell" after it where the employees will fill in the details. I was trying to come up with a macro that will essentially go through the column B to find consecutive entries a cell that has "values" and it should populate the % Complete column (C) with
    Incomplete (if there are no blank rows), e.g. cells B3-B5)
    Partially Incomplete if there are a few blank rows but has consecutive cells with values in the column (e.g. cells B6-B21)
    or Complete, if there are no cells that are next to each other, there's atleast one blank cell in between the values (e.g. cells B22-B39)

    That was my logic of trying to find the 5 Complete, but if you can think of any other way of figuring out the% Complete, I will appreciate it.

    Thanks again in advance for your time.
    Attached Files Attached Files

  5. #5
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Find consecutive non blank cells in a column

    Hi,

    Perhaps this array formula in C2 and copy down, though it will require some testing:

    =IF(A2="","",IF(COUNTBLANK($B3:INDEX($B3:$B$1000,MATCH(TRUE,INDEX($A3:$A$1000<>"",,),0)-1))=0,"Incomplete",IF(SUMPRODUCT(--(FREQUENCY(IF($B3:INDEX($B3:$B$1000,MATCH(TRUE,INDEX($A3:$A$1000<>"",,),0)-1)<>"",ROW($B3:INDEX($B3:$B$1000,MATCH(TRUE,INDEX($A3:$A$1000<>"",,),0)-1))),IF($B3:INDEX($B3:$B$1000,MATCH(TRUE,INDEX($A3:$A$1000<>"",,),0)-1)="",ROW($B3:INDEX($B3:$B$1000,MATCH(TRUE,INDEX($A3:$A$1000<>"",,),0)-1))))>1))>0,"Partially Complete","Complete")))

    You will also need to ensure that there is a final entry in column A to use as a 'marker' for the range to be considered for the final person (e.g. in your example, cell A40 must be non-blank so that the formula can determine the range for Frank Sinds).

    Regards
    Last edited by XOR LX; 11-06-2013 at 12:46 PM.

  6. #6
    Registered User
    Join Date
    09-27-2012
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: Find consecutive non blank cells in a column

    Thanks XOR LX.

    Unfortunately I am getting an error but will continue to test it. The issue might be that the final entry might not always be populated. Can this be accomplished any other way to overcome that limitation, as the last cell might be blank, Maybe a macro?

  7. #7
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Find consecutive non blank cells in a column

    Hi,

    In which cells are you getting the error? Are you testing on a sheet identical to the one you attached?

    Regards

  8. #8
    Registered User
    Join Date
    09-27-2012
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: Find consecutive non blank cells in a column

    I am testing using the same sheet. Please find it attached. I think the issue is that the last cell is not populated
    Attached Files Attached Files

  9. #9
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Find consecutive non blank cells in a column

    Ok, so if we're going to have a potential case where the last row in column A may not be populated, can we have some sort of upper bound on the number of cells to set for the range? I mean, we need to make sure we include all necessary data for e.g. Frank Sinds, so how else can we determine this?

    Perhaps we could say, for example, that the range of cells to be considered for any one person will never be greater than 50 rows? Or some other upper limit?

    Or do you have any other indicator(s) in mind? What would you expect a macro to look for that a worksheet formula could not?

    Regards

  10. #10
    Registered User
    Join Date
    09-27-2012
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: Find consecutive non blank cells in a column

    I was actually working on a macro but only got it partially done. Got stuck on it and it doesnt work properly. This is what I had so far:

    The "range" will depend on the week and what we get from vendors for that week, so for some weeks it can only be 2 records for Frank and some weeks it can be > 500 records for Frank

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    09-27-2012
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: Find consecutive non blank cells in a column

    Not sure if this makes sense or not. I couldnt think of any other way of handling this? Does this help or answer your questions? Maybe this does not need a macro but I wanted to automate the process to avoid copying and pasting the formula every day/week and automate it a little bit !! Thanks for helping me.

  12. #12
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Find consecutive non blank cells in a column

    I'm sure it does, but I'm afraid I won't be able to help you with a VBA solution. Hopefully someone with more expertise in that area will pick up on this thread shortly. In the meantime, I'll ask for some support.

    Regards

  13. #13
    Registered User
    Join Date
    09-27-2012
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: Find consecutive non blank cells in a column

    Thanks XOR LX. Maybe the approach can be that I use the macro to "paste" the formulae in the corresponding "C" cell, if there's a way to solve the last cell not populated issue. I am also not sure how to tackle this. Thanks for your help. I do appreciate it.

  14. #14
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Find consecutive non blank cells in a column

    Ok, but surely you're in a position to name a suitable upper limit, aren't you? I mean, you say it could be 500, so can't we say, e.g. 5000 and be 99.999% certain that this will cover us? Do you see what I'm saying?

    Regards

  15. #15
    Registered User
    Join Date
    09-27-2012
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: Find consecutive non blank cells in a column

    Yes yes, the upper limit can be set to 500, it will cover 99.999 % of cases. And I can also populate the column A with Names as a part of my macro to make sure that column A always has values and so they are not blank but have the Names, if this will help.

    Edit:
    Just attached a file with the column A populated, as to what I meant.
    Attached Files Attached Files
    Last edited by desibabuji; 11-06-2013 at 04:12 PM. Reason: Added attachment

  16. #16
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Find consecutive non blank cells in a column

    Hi Desi,

    I'll try my hand tomorrow if you still need it.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  17. #17
    Registered User
    Join Date
    09-27-2012
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: Find consecutive non blank cells in a column

    Hi xladept.

    Thanks, I am still trying to figure it out. I have been trying to approach it in a different way now. I was trying to convert the formula that XOR LX provided to VBA by recording the macro but I am getting an error "Unable to set FormulaArray property of the Range class", I think it is because it is too long a formula.

    I will really appreciate if you can have a look at it. I am stuck with these two approaches but I am sure there's another way to do it

    Please Login or Register  to view this content.

  18. #18
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Find consecutive non blank cells in a column

    Hi desibabuji

    This Code is in the attached and appears to work on your Sample File. Run the Code from the Button on Sheet BEFORE (2).
    Please Login or Register  to view this content.
    Attached Files Attached Files
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  19. #19
    Registered User
    Join Date
    09-27-2012
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: Find consecutive non blank cells in a column

    Hi jaslake.

    Thanks so much for the code. Will it be difficult to alter it to work with the condition when column A is populated with names, as in the BEFORE sheet attached? I mean the code works but then while I was working on the solution, I realized that if the column A is fully populated, I could also accommodate another macro with the new format

    What I mean is that instead of looking for "blank cells" in the column, can the code be modified to insert the column C values when the Name in column A changes, eg from John to Mario or Frank , (row 2, 6 and 22)!

    If it is too much of effort then please let me know, I can go ahead and revert my approach to what I originally had, this is more of a nice to have. Thanks a lot for your time and effort. I really do appreciate it.
    Last edited by desibabuji; 11-07-2013 at 06:09 PM.

  20. #20
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Find consecutive non blank cells in a column

    Hi desibabuji

    I'd be happy to look at the revision but I need to tell you, I'm not at all convinced that the Code provided will work on your Live File. There's too much logic involved.

    I'd like you to provide more Test Data...perhaps a dozen items or so with differing scenarios. Perhaps 4 to 5 of each, interspersed.

    Present the new Sample Data in the Format you desire...Expected Results would be nice...we'll see what we can do.

  21. #21
    Registered User
    Join Date
    09-27-2012
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: Find consecutive non blank cells in a column

    Hi jaslake

    Please find attached an updated sample sheet.

    What it is, is kind of a log book for drop off and pick up, we get and generate this report every week for packet pickup and drop off. Originally at the beginning of the month/quarter it only has the green rows (eg 2, 6 and 22) per employee and values that are in column F. Once and when the tasks are performed, the employees/route agents/drivers insert new lines and fill in the details. eg line 11, 14 16 and so on.

    So what I wanted to do was have a macro that populates the column (I), based on empty cells in column F to identify and summarize who has completed the entries and who still has to complete the entries at the end of the week. The report can have thousand of rows depending if it is weekly, monthly, quarterly or annual. The format remain the same. So instead of manually creating and browsing through the report. I wanted a macro that can insert the values in column I, that way I can filter and then copy/paste the data to send out as reminders etc.

    if you have any questions about the data please let me know. Thanks a lot for your help.
    Attached Files Attached Files

  22. #22
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Find consecutive non blank cells in a column

    Hi desibabuji

    Please do this
    I'd like you to provide more Test Data...perhaps a dozen items or so with differing scenarios. Perhaps 4 to 5 of each, interspersed.

    Present the new Sample Data in the Format you desire...Expected Results would be nice...we'll see what we can do.

  23. #23
    Registered User
    Join Date
    09-27-2012
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: Find consecutive non blank cells in a column

    Hi jaslake.

    Thanks for the quick reply. Please find attached an updated file. Do you think this has enough sample data? Please let me know if you need more infromation. Thanks again for all your help.

    Before_3 has the input Data and Sheet1 has the expected output. Regards !
    Attached Files Attached Files

  24. #24
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Find consecutive non blank cells in a column

    Here is a macro solution:
    Please Login or Register  to view this content.

  25. #25
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Find consecutive non blank cells in a column

    Hi desibabuji

    With your new Format it'll involve a rather significant rewrite of the Code. I'll look at it this afternoon as time permits.

  26. #26
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Find consecutive non blank cells in a column

    Sorry, I missed the second page, re-writing my code for your new sample:
    Please Login or Register  to view this content.

  27. #27
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Find consecutive non blank cells in a column

    Hi desibabuji

    Try yudlugar's Code...let us know.

  28. #28
    Registered User
    Join Date
    09-27-2012
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: Find consecutive non blank cells in a column

    Thanks yudlugar for your code, it works. This is awesome.
    Also thanks jaslake for your original code.

    I do appreciate your time and help. Thanks again.

+ 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. Replies: 2
    Last Post: 07-25-2013, 01:01 PM
  2. Replies: 1
    Last Post: 05-29-2013, 10:35 AM
  3. Looking to create a macro that will skip blank cells in a column, find data cells
    By crayzwalz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2013, 09:01 AM
  4. [SOLVED] find blank cells in column and average the cells below
    By desibabuji in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-03-2013, 12:03 PM
  5. [SOLVED] Need to find two consecutive identical cells (in a column).
    By How did I get here? in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-03-2006, 03:15 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