+ Reply to Thread
Results 1 to 6 of 6

What is wrong with this for loop?

  1. #1
    Forum Contributor
    Join Date
    09-15-2012
    Location
    Jamaica
    MS-Off Ver
    Microsoft 365
    Posts
    244

    What is wrong with this for loop?

    Hello, I am having a challenge with the code below. I have a list of names on sheet3 column A4 to A10, the list of names are the only people that should be able to broadcast an email from the application. When the person enter their username in the textbox, if the name entered is not in the range sheet3 column A4 to A10, then a message should return saying that you are not authorized for email broadcasting. The userform should not close, but the username textbox (textbox1) should have focus.

    When i try the code below, it triggers the message if the username i entered is not in the range, but the challenge is, it also triggers the message if I enter the correct name in the textbox. I think this means it’s not reading from the right sheet column A.

    Kindly help, thank you in advance.


    Please Login or Register  to view this content.

  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: What is wrong with this for loop?

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: What is wrong with this for loop?

    Another suggestion:

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

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

    Re: What is wrong with this for loop?

    Try this.....
    Please Login or Register  to view this content.
    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.

  5. #5
    Forum Contributor
    Join Date
    09-15-2012
    Location
    Jamaica
    MS-Off Ver
    Microsoft 365
    Posts
    244

    Re: What is wrong with this for loop?

    Thank you all for responding so quickly and accurately, they all worked. Sorry for thanking so late.

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

    Re: What is wrong with this for loop?

    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. Wrong coding or RANDBETWEEN is wrong?
    By zbor in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 07-31-2013, 10:01 AM
  2. [SOLVED] What is wrong with this code? (Loop through WBs in folder - open, edit, save & close)
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-04-2013, 07:49 PM
  3. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  4. If Loop Wrong Usage?
    By coconutmango in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-23-2011, 08:11 PM
  5. What's wrong with my loop ?
    By Grek in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-13-2006, 02:23 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