+ Reply to Thread
Results 1 to 9 of 9

Refining when a worksheet_Change event runs with perhaps ISodd or similar

  1. #1
    Registered User
    Join Date
    09-14-2011
    Location
    Newton Abbot, England
    MS-Off Ver
    Excel 2007
    Posts
    23

    Refining when a worksheet_Change event runs with perhaps ISodd or similar

    Thank you to Bob Phillips for getting me this far.

    I am having problems with refining when code runs.

    this is the code so far
    Please Login or Register  to view this content.
    Whilst this code works perfectly it does not give me the flexibility of being able to be more specific as to when it runs

    I can place a marker in a column (at row 8 for example) which i will simply hide by making it the same colour as its background.
    then the code needs to run only when the row is an odd value ant within a certain range (eg from 9 to 21)
    I suspect i need to use the Isodd or iseven syntax but i am struggling as to how

    This or a very similar post has been placed in Mr Excel also but i seem to be unable to access their site cureently so i am unable to link (currently)

    As i am TRYING (slowly) to learn as i go PLEASE rather than just fix my issue notate things and hopefully one day i will be more capable.

    Thank you in advance
    Last edited by Wobbles; 09-19-2011 at 08:56 AM.

  2. #2
    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,464

    Re: Refining when a worksheet_Change event runs with perhaps ISodd or similar

    Rather than saying:

    Please Login or Register  to view this content.

    with your code within the IF/END IF block, use:

    Please Login or Register  to view this content.

    Then you can also use:

    Please Login or Register  to view this content.

    *However*, don't put:

    Please Login or Register  to view this content.

    at the beginning of your code. Put it just prior to where you will make a change to the sheet, thus potentially firing the Change event again.

    Not sure about the last point ;-(

    However, based on these suggestions, your code becomes:

    Please Login or Register  to view this content.


    Regards
    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


  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Refining when a worksheet_Change event runs with perhaps ISodd or similar

    There is no ISODD in VBA, you need something like
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    09-14-2011
    Location
    Newton Abbot, England
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Refining when a worksheet_Change event runs with perhaps ISodd or similar

    Thank you both i am however confused or more likely stupid


    Quote Originally Posted by royUK View Post
    There is no ISODD in VBA,
    you state the above however TMShucks writes
    Please Login or Register  to view this content.
    There is something i am not grasping
    Please comment any code so that I learn from it

  5. #5
    Registered User
    Join Date
    09-14-2011
    Location
    Newton Abbot, England
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Refining when a worksheet_Change event runs with perhaps ISodd or similar

    Please ignore my last , i think im getting there .... onward and again thanks

  6. #6
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Refining when a worksheet_Change event runs with perhaps ISodd or similar

    RoyUK is correct. There isn't an IsOdd() function in VBA. I think TMShucks assumed that you had written your own IsOdd() function.

    The quickest way to check if an integer, x, is odd is to use this expression:
    Please Login or Register  to view this content.
    If you want, you can then wrap it in a function called IsOdd() like this:
    Please Login or Register  to view this content.
    Hope that helps,

    Colin

    RAD Excel Blog

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Refining when a worksheet_Change event runs with perhaps ISodd or similar

    Thinking about it you could use
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    09-14-2011
    Location
    Newton Abbot, England
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Refining when a worksheet_Change event runs with perhaps ISodd or similar

    Thank you everyone , the beauty of forums is combined effort .
    One day i strive to be the geniuses you guys obviously are - ( but im a realist )

    I'm not thick but VBA makes me doubt it :-)

  9. #9
    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,464

    Re: Refining when a worksheet_Change event runs with perhaps ISodd or similar

    IsOdd isn't a "function" that I have used. As it was there, I assumed it was valid but I had nothing to test the code with so I just massaged it as it was.

    @Wobbles: thanks for the rep

    Regards

+ 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