+ Reply to Thread
Results 1 to 4 of 4

For each loop not working

  1. #1
    Registered User
    Join Date
    06-03-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    46

    For each loop not working

    Hi guys,

    The code that I am working on is giving me some trouble:

    I have a list of text values with intermittent empty values:

    text1
    text2
    (empty)
    text3
    (empty)
    (empty)
    text4

    I want my code to perform a number of actions for each text# in the range. I am using a for each loop:

    Please Login or Register  to view this content.
    The code works fine, but there is 1 problem: I want the loop to skip the empty values in the textlist. I tried adding the following code:

    Please Login or Register  to view this content.
    But this keeps asking to add a value behind the For statement.

    I have been looking for solutions for several hours, but I cannot find a solution. Do you guys have any suggestions?

    BTW: the list range gets its values from another sheet using a simple = sheet1'!A1 statement.

    All help is appreciated!

    Thanks!

    Schzuki

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: For each loop not working

    First of all congratulation. Netherlands beat England today in T20 World cup 2014 by 45 runs.

    Now your problem.....

    I think the code should be like this.....

    Please Login or Register  to view this content.
    See if this helps.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Registered User
    Join Date
    06-03-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: For each loop not working

    Go dutchies! That makes it 1 out 4 doesn't it? (we will get there eventually)

    Your solution worked perfectly! A simple solution to a vague problem, I like it...

    Thanks so much for your help!

    Schzuki

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: For each loop not working

    Glad to help you. Thanks for the feedback.
    If that takes care of your question, please mark your thread as solved.
    Moreover you may also click on * (star) to Add Reputation to those who have put their time and efforts to help you in this forum. This is another way to say thanks to them.

+ 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. Vba Loop not working
    By dahveedoff in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-27-2014, 03:57 PM
  2. [SOLVED] Do while loop not working
    By rikkyshh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-09-2013, 01:47 PM
  3. Why is this Do Loop not working right?
    By evilrtc in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-21-2007, 01:52 AM
  4. Loop not working!!
    By Simon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-02-2005, 12:05 PM
  5. Do...Loop not working
    By Sunny Lin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-13-2005, 09: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