+ Reply to Thread
Results 1 to 10 of 10

Help With Looping Macro

  1. #1
    Registered User
    Join Date
    05-16-2017
    Location
    New Jersey
    MS-Off Ver
    2010
    Posts
    51

    Exclamation Help With Looping Macro

    How could I make the below VBA loop until a blank cell?

    Please Login or Register  to view this content.
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Last edited by lsantana; 07-28-2018 at 06:41 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,756

    Re: Help With Looping Macro

    Add lines in red:

    Please Login or Register  to view this content.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,756

    Re: Help With Looping Macro

    However, note that is not a best practice from a user interface standpoint. If there is more than one blank cell, you are going to make the user run this over and over again. Instead you should notify him of all blank cells in one go. What is wrong with the version you started with?

  4. #4
    Registered User
    Join Date
    05-16-2017
    Location
    New Jersey
    MS-Off Ver
    2010
    Posts
    51

    Exclamation Re: Help With Looping Macro

    Sorry 6StringJazzer for the mistake above will read the rules today.

    Sorry my post wasn't more detailed. The VBA above i originally wrote works perfect but only works for row 7. I need the above VBA to do the same for row 8 if there's something written on cell "B8" and the same on "B9" ect. I've attached the forum which the code is running on. So you may get a better understanding.
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Help With Looping Macro


    Explain in plain text what is the purpose of your procedure …

  6. #6
    Registered User
    Join Date
    05-16-2017
    Location
    New Jersey
    MS-Off Ver
    2010
    Posts
    51
    Quote Originally Posted by Marc L View Post

    Explain in plain text what is the purpose of your procedure …

    When someone goes in the form and writes something on the first cell which will be “B7” or “B8” or “B9” ect and tries to save. It will prompt them if something is missing in the entire row and indicate which cell they left blank. So for example they write something on “B10” and forgot to input something on “J8” when they go to hit save it prompt them they didn’t fill out “J8”. The code above works perfectly but for only row 7 I need the code to loop and go to the next cell down the check if something was written on “B8” and perform all the checks required as it happen ong row 7.

    I could simply copy and paste the code 100 times and set the ranges per row but trying do the use best efficiency and not have a VBA code 10,000 lines long and possibly prompt me it’s s to long. Would just rather see 15 lines of code and looping.

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Help With Looping Macro


    Which columns may be blank ?

    If there is a huge number of rows to check, the control may stop at the first row with any missing entry …

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,740

    Re: Help With Looping Macro

    How about
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    05-16-2017
    Location
    New Jersey
    MS-Off Ver
    2010
    Posts
    51

    Re: Help With Looping Macro

    Quote Originally Posted by Fluff13 View Post
    How about
    Please Login or Register  to view this content.
    Fluff13 thank you so much your code worked I just altered it a bit since the offset was off by 1 cell for the divisions in range "p7:x7" and was still letting me save it if something wasn't marked in those ranges. Below is the altered code and works perfectly thank you again.


    Please Login or Register  to view this content.

  10. #10
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,740

    Re: Help With Looping Macro

    Glad to help & thanks for the feedback

+ 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] Macro to create a looping macro to populate another worksheet.
    By sungen99 in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 06-22-2016, 10:53 AM
  2. Help with looping my macro
    By dry in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-03-2015, 11:19 AM
  3. Looping Macro
    By ashar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-20-2013, 07:50 PM
  4. [SOLVED] Help with looping a macro
    By jumpingoff in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-27-2012, 04:15 PM
  5. Looping Macro
    By ExcelGuy160 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-14-2010, 06:37 PM
  6. Looping macro
    By mbenazeraf in forum Excel General
    Replies: 13
    Last Post: 01-18-2010, 02:20 PM
  7. Looping a macro
    By Toadums in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-31-2008, 01:07 PM

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