+ Reply to Thread
Results 1 to 4 of 4

VBA - For Each Loop - Cannot check all cells in range if first cell is not populated

  1. #1
    Registered User
    Join Date
    05-31-2019
    Location
    London
    MS-Off Ver
    Windows 10
    Posts
    1

    Post VBA - For Each Loop - Cannot check all cells in range if first cell is not populated

    Hi there,

    I am relatively new to VBA and I am trying to create some validation rules for a data entry sheet end users will be populating.

    I am using a For Each loop to verify the data in a particular column. The code below works if the cells are populated in order (top to bottom). However, if I copy and paste multiple incorrect values into the range at once, or if I populate a cell further down in the range leaving the top cell blank, the validation only works for the first cell in the range and does not loop through.

    I cannot seem to make this work without being stuck in a continuous error loop. Is there a better way to do this?

    Any advice would be appreciated!


    Please Login or Register  to view this content.
    Last edited by RSmith93; 05-31-2019 at 04:31 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: VBA - For Each Loop Help Required

    Welcome to the board.

    Please take a few minutes to read the Forum Rules, and then edit your post to wrap your code with CODE tags.

    Thanks.

    EDIT: Thank you.
    Last edited by shg; 06-01-2019 at 11:30 AM.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: VBA - For Each Loop - Cannot check all cells in range if first cell is not populated

    I can't tell from your code what behavior you want; can you clarify?

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: VBA - For Each Loop - Cannot check all cells in range if first cell is not populated

    Please Login or Register  to view this content.
    ** No sample file = no check tsk, tsk, tsk
    Last edited by protonLeah; 06-01-2019 at 03:12 PM.
    Ben Van Johnson

+ 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] Assistance required with VBA loop
    By sintek in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-04-2016, 08:38 AM
  2. Object Required error in set loop
    By Tonan230 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-26-2016, 05:43 PM
  3. Help Required for Loop with formula.
    By dfurn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-09-2015, 07:34 AM
  4. Do Until loop or equivalent required
    By Nonboff in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-11-2009, 05:54 AM
  5. Loop & Offset assistance required
    By Digory in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-20-2007, 04:30 PM
  6. Object required error in a loop
    By yellephant in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-29-2007, 12:22 PM
  7. Help required with a simple Loop
    By Pedros in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-27-2006, 08:00 AM

Tags for this Thread

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