+ Reply to Thread
Results 1 to 5 of 5

Macro ignoring Loop

  1. #1
    Registered User
    Join Date
    06-18-2009
    Location
    America
    MS-Off Ver
    Excel 2003
    Posts
    8

    Macro ignoring Loop

    I have writtent the following macro, which is called in a larger macro. It is supposed to search a "Data" worksheet for names which do not appear in a "Staff List" worksheet in another spreadsheet, and add any missing names to the "Staff List" worksheet. However, when I run this macro, it will find the first missing name, add it appropriately, and then end the macro, ignoring the loop. There are many missing names which it should be finding, but it only finds one every time it runs. It is a different one every time. Any suggestions?



    Please Login or Register  to view this content.
    Last edited by chcwebb; 06-18-2009 at 04:53 PM. Reason: Adding Code Tags

  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: Macro ignoring Loop

    Welcome to to the forum, chcwebb.

    Please take a few minutes to read the forum rules, and then edit your post to add code tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Macro ignoring Loop

    Your code does exactly what you have it coded to do - It loops once

    Within your loop you select the last used cell
    Please Login or Register  to view this content.
    You then select the next row and populate that with formulas

    Before the Loop command at the end of your Do Loop you then select the next row down which is blank
    Please Login or Register  to view this content.
    P.S Macros can be coded do that you do not need to select cell all the time
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  4. #4
    Registered User
    Join Date
    06-18-2009
    Location
    America
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Macro ignoring Loop

    What is happening, if I am rereading my code correctly, is:

    If the name in "Data" is not in "Staff List" Then

    Open "Staff List", go to the first blank row, and paste the appropriate information into the row.

    Then go back to the "Data" worksheet, go down a row, and keep on searching.

    Since the Selection.End(xlDown).Select is in the "Staff List" sheet, and the macro is cycling through values in the "Data" sheet, this should not end the macro prematurely, right?

  5. #5
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Macro ignoring Loop

    Can you post a copy of the book - Make sure any sensitve data is changed

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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