+ Reply to Thread
Results 1 to 5 of 5

VBA code will not let me pass to next cell

  1. #1
    Forum Contributor
    Join Date
    08-31-2007
    MS-Off Ver
    2010
    Posts
    130

    VBA code will not let me pass to next cell

    I have entered the following code to select cell F7 when I6 equals nothing.
    This is done to ensure the person filling out the form does not enter bad info into cell F7.
    I'm trying to hold them on this cell F7 until they follow the rules set for them.

    Please Login or Register  to view this content.
    Now It always selects F7 regardless of what I6 equals.
    Any ideas?

  2. #2
    Forum Contributor
    Join Date
    08-31-2007
    MS-Off Ver
    2010
    Posts
    130

    Re: VBA code will not let me pass to next cell

    I have changed the Code to the following.

    Please Login or Register  to view this content.
    But still not working.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: VBA code will not let me pass to next cell

    What you are doing is saying, if a cell (any cell) is selected, is it cell I6? So, if it isn't ... Intersect(Target, Range("I6")) Is Nothing ... then select cell F7. In other words, whatever cell you select, if it isn't cell I6, select cell F7.

    But you can't say, If Range("I6") ="" Then Range("F7").Select because, unless I6 does have something in it, it the code will select F7 ... and you won't be able to select I6 to put something in it. Catch 22.

    I think, if you want something putting in cell I6, that's what you need to monitor, and that's what you need to select.

    The other issue is that you are selecting a cell within a Worksheet Selection Change event handler, so there's a serious danger that you will end up in a loop.

    You need to add Application.EnableEvents = False before the select and Application.EnableEvents = True after.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Contributor
    Join Date
    08-31-2007
    MS-Off Ver
    2010
    Posts
    130

    Re: VBA code will not let me pass to next cell

    If Range("I6") = "You must have written approval to enter that short of a turn around" Then Range("F7").Select

    Worked

    Thank you TMS

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: VBA code will not let me pass to next cell

    You're welcome.

+ 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. Code to Pass Worksheet Change in Excel Addin
    By Redled89 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-10-2015, 04:26 PM
  2. Pass enter key code to image click event in VBA
    By Sunil Dushila in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-09-2015, 10:11 AM
  3. [SOLVED] Help with VB Code to pass a selection to another workbook's slicer
    By rv02 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-08-2015, 01:11 AM
  4. Replies: 1
    Last Post: 10-22-2014, 08:32 AM
  5. [SOLVED] Pass Variable in VB Code
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-05-2013, 04:49 AM
  6. Replies: 3
    Last Post: 06-07-2012, 07:25 PM
  7. [SOLVED] Analyze Within An Array and Pass Back Once vs. Pass at each applicable Instance
    By AlvaroSiza in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-11-2012, 05:25 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