+ Reply to Thread
Results 1 to 7 of 7

Loop through strings stop when strings change and start looping in the next column...?

  1. #1
    Registered User
    Join Date
    11-25-2013
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    19

    Loop through strings stop when strings change and start looping in the next column...?

    Hi, I am looking to find the syntax to make a loop that does this:

    I have 3 columns.

    The first column holds repeating strings, after an irregular number of rows the string changes e.g. aa, aa, aa,... bb, bb,bb,bb,bb,... cc,cc,cc

    I would like to know how I can tell the for loop to loop through aa, than loop through column 2 and 3 (to find the items I am looking for) and then continue looping through column 1 with bb.

    I added arrows in the excel file to indicate the route the loop should take.

    Any suggestions would be much welcome.
    Attached Files Attached Files
    Last edited by Prexcel; 12-17-2013 at 04:51 PM.

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,097

    Re: Loop through strings stop when strings change and start looping in the next column...?

    Try
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-25-2013
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Loop through strings stop when strings change and start looping in the next column...?

    Hi PCI,

    it seems to do exactly what I want.
    And that is why it is awesome. But I have to play with it for a while and understand all its moving parts and adjust it a little bit.
    But I understand enough of the code to know that you just helped me out massively.

    Thank you very much!

  4. #4
    Registered User
    Join Date
    11-25-2013
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Loop through strings stop when strings change and start looping in the next column...?

    Dear PCI,

    I wrote this code to find a this string "+" in the 2nd Column and this string "TP" in the 3rd column.
    It work, but since I am a beginner it is probably a sub optimal solution for what I am doing. If you have a suggestion for improving the code I would be most thankful.

    However, you have helped out already and the problem itself is solved!


    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Loop through strings stop when strings change and start looping in the next column...?

    Will your data always be sorted according to column F?

  6. #6
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Loop through strings stop when strings change and start looping in the next column...?

    Here's also an alternative:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-25-2013
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Loop through strings stop when strings change and start looping in the next column...?

    Hi Berlan,
    yes, it will always be sorted according to F!
    Thanks for the code, that looks great. I will check it out after work. Thanks a lot!

+ 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. Change Cell Strings in Column to Replace Specifically the Second Character
    By Steve794421 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-21-2013, 09:36 AM
  2. [SOLVED] loop to match if shorter strings appears in longer strings
    By mcdermott2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-19-2012, 08:07 PM
  3. Replies: 2
    Last Post: 06-16-2012, 06:20 PM
  4. SQL Strings, Looping and Using Date Values
    By jagstirling in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-03-2010, 05:19 PM
  5. Looping though multiple strings
    By insanity66 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-27-2010, 10:55 AM

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