+ Reply to Thread
Results 1 to 5 of 5

Creating a loop to find an empty cell

  1. #1
    Registered User
    Join Date
    12-15-2018
    Location
    Salt Lake City
    MS-Off Ver
    Office
    Posts
    2

    Creating a loop to find an empty cell

    How do I create a loop that increments a variable until an empty cell is found? And once that cell is found, how do I get the variable to hold the row number of the next empty row?

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Creating a loop to find an empty cell

    e.g.:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    12-15-2018
    Location
    Salt Lake City
    MS-Off Ver
    Office
    Posts
    2

    Re: Creating a loop to find an empty cell

    thank you for these examples, if I wanted to start from the end of a sheet and work backwards to find the cell with content would I do something like this Cells(5, 1).End(xlUp).Row.Select?

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Creating a loop to find an empty cell

    Hello NVL,

    You would use this...
    Please Login or Register  to view this content.
    F.Y.I. in VBA it is rare you will ever need to select an object before performing an operation on it. Selecting also slows your code code considerably.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Creating a loop to find an empty cell

    Quote Originally Posted by NVL View Post
    ... if I wanted to start from the end of a sheet and work backwards to find the cell with content ... ?
    It depends on what is the "content", and you define the starting position of the loop, as Leith Ross shows or from some predetermined value, for example:
    (the loop counter, of course, is reduced by some value)
    Please Login or Register  to view this content.

+ 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] vba code to find and paste data to next empty cell, not last empty cell
    By hkbhansali in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-21-2018, 10:48 AM
  2. [SOLVED] Creating empty Zip folders (Loop)
    By paularthur90 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-21-2016, 06:39 AM
  3. Replies: 5
    Last Post: 05-13-2014, 10:19 AM
  4. Need to find empty filled cells in a column and copy to the empty cell below
    By Grahamfeeley in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-30-2014, 10:09 AM
  5. [SOLVED] Loop to find cells based on criteria, enter formula into next empty column
    By cschoyer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-10-2012, 03:32 PM
  6. [SOLVED] VBA: Using a Loop to find an empty cell
    By GalmOne in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-31-2012, 09:17 AM
  7. Loop to find next empty cell to the right not working.
    By Casey in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-04-2006, 10:16 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