+ Reply to Thread
Results 1 to 18 of 18

Simpler way than 11+ If Statements?

  1. #1
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Simpler way than 11+ If Statements?

    Hi
    I have a worksheet change event that looks at a range of 11 cells
    If any of those changed, then there are 11 If/Else statements under it to either hide or unhide rows on a different tab.
    My question is, do I have to do this 11 times or is there a cleaner/better way?
    I've named all the various ranges in a similar fashion.

    Please Login or Register  to view this content.
    Last edited by ker9; 08-28-2015 at 04:20 PM.

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Simpler way than 11+ If Statements?

    Post all the code, please.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  3. #3
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Simpler way than 11+ If Statements?

    That was almost all the code - all 11 would be about the same. I didn't set them all up wondering if there was something better.

    Please Login or Register  to view this content.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Simpler way than 11+ If Statements?

    Hi ker9

    Not tested...
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Simpler way than 11+ If Statements?

    Hi jaslake - I appreciate your help, but I'm not sure I understand why that is any better than the 11 If statements. I still have to set up 11 sets. Thank you!

  6. #6
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Simpler way than 11+ If Statements?

    Maybe:

    Please Login or Register  to view this content.
    If you are happy with my response please click the * in the lower left of my post.

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

    Re: Simpler way than 11+ If Statements?

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 08-28-2015 at 03:55 PM.
    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.

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Simpler way than 11+ If Statements?

    Hi ker9

    Not...only 2

    This sets up the first set
    Please Login or Register  to view this content.
    This sets up the second
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Simpler way than 11+ If Statements?

    stnkynts - works beautifully!! Thank you!

  10. #10
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Simpler way than 11+ If Statements?

    AlphaFrog - I get a "Range of Object" error on the 2nd If statement

    Please Login or Register  to view this content.

  11. #11
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Simpler way than 11+ If Statements?

    That was almost all the code - all 11 would be about the same. I didn't set them all up wondering if there was something better.
    Okay, that's cool I wanted to make sure what you had followed the complete pattern of what you were doing. If there was more I wanted to see what you wrote.

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

    Re: Simpler way than 11+ If Statements?

    Quote Originally Posted by ker9 View Post
    AlphaFrog - I get a "Range of Object" error on the 2nd If statement

    Please Login or Register  to view this content.
    Sry, I edited it above in post #7

  13. #13
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Simpler way than 11+ If Statements?

    jaslake - I get it now - thanks!

  14. #14
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Simpler way than 11+ If Statements?

    or maybe so (using a code from AlphaFrog)
    Please Login or Register  to view this content.
    edited
    it would be better
    Please Login or Register  to view this content.
    Last edited by nilem; 08-28-2015 at 04:20 PM.

  15. #15
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Simpler way than 11+ If Statements?

    AlphaFrog - working perfectly now.
    Now my only problem is which one to choose
    Thank you all very, very much and I learned quite a bit, too!

  16. #16
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Simpler way than 11+ If Statements?

    nilem- works great, too! (but I understand it the least, I'll think on it)

  17. #17
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Re: Simpler way than 11+ If Statements?

    nilem - works great, too! (but I understand it the least so I'll need to think on it)

  18. #18
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Simpler way than 11+ If Statements?

    Why do you care whether it's hidden or not since you're going to hide it anyway?

    /AlphaFrog

    Please Login or Register  to view this content.
    /Nilem

    Please Login or Register  to view this content.
    Last edited by xladept; 08-28-2015 at 04:37 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

+ 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. Replies: 0
    Last Post: 09-29-2013, 04:50 AM
  2. Help make this simpler (if statements)
    By harmbasi in forum Excel General
    Replies: 3
    Last Post: 04-13-2012, 02:58 PM
  3. IF STATEMENT - must be a simpler way
    By tlapointe1970 in forum Excel General
    Replies: 1
    Last Post: 07-26-2011, 05:01 PM
  4. A simpler way to do nested vlookups?
    By bsoper in forum Excel General
    Replies: 4
    Last Post: 01-06-2011, 03:43 PM
  5. Creating Simpler Macro
    By d4ftpuNK in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-26-2009, 02:04 AM
  6. is there not a simpler way
    By T.c.Goosen1977 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-05-2006, 03:55 AM
  7. Complex formula vs. simpler
    By GerryK in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-06-2005, 11:35 AM
  8. How can I make this simpler?
    By Sethaholic in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-13-2005, 04:05 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