+ Reply to Thread
Results 1 to 13 of 13

Perform Loop until column reaches two consecutive blanks

  1. #1
    Registered User
    Join Date
    07-15-2015
    Location
    USA
    MS-Off Ver
    2007
    Posts
    12

    Perform Loop until column reaches two consecutive blanks

    I have information that's not always together in column A (i.e. there may be one blank cell between chunks of information).

    In column I, I wish to type in "none" in all of its blank cells UNTIL two consecutive blanks in column A are reached.

    I've included an example below.

    To be more direct, I wish to parse through column A and count all the rows until there are two consecutive blank cells. For all the rows that are counted, I wish to write "none" in column I.

    COLUMN A | COLUMN I
    data | none
    data | none
    data | data
    data | data
    data | data
    <blank> | none
    data | none
    data | data
    data | none
    data | none
    <blank> | STOP
    <blank>
    <blank>

    I've included "|" to help identify the diff between column A and column I
    I would definitely appreciate if anyone could help me with this!!
    Last edited by reshi; 07-29-2015 at 12:30 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,433

    Re: Perform Loop until column reaches two consecutive blanks

    Are the two blank cells indicative of the end of data? That is, there is no more data in column A after the two blank cells.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    07-15-2015
    Location
    USA
    MS-Off Ver
    2007
    Posts
    12

    Re: Perform Loop until column reaches two consecutive blanks

    yes there should be no more data after the two blank cells.

  4. #4
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Perform Loop until column reaches two consecutive blanks

    Please Login or Register  to view this content.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,433

    Re: Perform Loop until column reaches two consecutive blanks

    No loop required ...

    Please Login or Register  to view this content.

    Regards, TMS

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Perform Loop until column reaches two consecutive blanks

    Perhaps.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  7. #7
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Perform Loop until column reaches two consecutive blanks

    Gee golly that's smart. I didn't think to ask if there was no data after the double blank.

  8. #8
    Registered User
    Join Date
    07-15-2015
    Location
    USA
    MS-Off Ver
    2007
    Posts
    12

    Re: Perform Loop until column reaches two consecutive blanks

    Norie, your code only works for single blank cells in column A. I need it to work for all cells (blank or nonblank) UNTIL two consecutive blank cells are reached. it stops perfectly after noticing there's more than one blank cell, but "None" doesn't show up for all the cells in column I that I need it to show up in.

  9. #9
    Registered User
    Join Date
    07-15-2015
    Location
    USA
    MS-Off Ver
    2007
    Posts
    12

    Re: Perform Loop until column reaches two consecutive blanks

    TMS, your code worked!!!

    Thank you a bunch

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,433

    Re: Perform Loop until column reaches two consecutive blanks

    You're welcome.


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  11. #11
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Perform Loop until column reaches two consecutive blanks

    Which column(s) are you looking in for blanks?

    The code I posted looks in column A and it does works for all blanks.

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Perform Loop until column reaches two consecutive blanks

    Also, what do you mean that you want the code to work for both blank and non-blank cells?

  13. #13
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,433

    Re: Perform Loop until column reaches two consecutive blanks

    @Norie: the problem is perhaps not well explained. My understanding is that, wherever you see "none" in the column I data, that will, in fact, be blank and those are the blank cells that need the word "none" inserting. I think the single blank cell in column A is a bit of a red herring.

    My code could be reduced to a single line, as yours is, but I prefer to break it down. I find it easier to understand the steps I'm going through and, subsequently, to debug it.

    Please Login or Register  to view this content.

    This is looking at blank cells in column I, not column A, although it is limited by the number of rows of data in column A. Again, the "two blank cells" is another red herring ... he is just using that as the indicator that there is no more data (as questioned in post #2 and answered in post #3)


    Regards, TMS

+ 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. When my do while loop reaches the end it goes to debut instead of stopping why?
    By joshnathan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-13-2014, 12:36 PM
  2. how to perform 2 consecutive conditional formulas for same row
    By Curt108 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-22-2013, 10:59 AM
  3. Perform Calc On Specific Number Of Cells (Avoiding Blanks)
    By Phillycheese5 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-19-2013, 02:21 PM
  4. Replies: 2
    Last Post: 01-18-2013, 06:06 PM
  5. Scan a Column A (numbers and blanks) and copy its contents WITHOUT BLANKS into Column B
    By bighandsam in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2012, 05:16 PM
  6. [SOLVED] Loop that finds blanks, then subtotals values into different column
    By Bevy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-24-2006, 11:45 AM
  7. Replies: 2
    Last Post: 09-15-2005, 08:05 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