+ Reply to Thread
Results 1 to 6 of 6

Condesning/Automating Nested If statements

  1. #1
    Registered User
    Join Date
    06-20-2019
    Location
    Minnesota
    MS-Off Ver
    Office 2019
    Posts
    39

    Condesning/Automating Nested If statements

    Hello! I am a novice with VBA, so I need some assistance. I have manually entered a large nested If statement in my VBA. The overview is that I would like to create passwords (which can be found in a hidden column and also happen to be the users first name) that users must enter and click a button (which runs this macro) in order view the cells that "belong" to them. Passwords are simply their names, which can be found in column Q, starting in row 4. If the user enters their name (aka password), I would like it to check against Column B, which also has their name in it. The macro should unhide all the rows that have their name/password in column B. Here is my large and obnoxious VBA that needs to be automated/cleaned up. An example is that the password "Chris" should reveal rows 21-25 only.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Condesning/Automating Nested If statements

    Option 1.
    Use the Select Case Funtion to reduce your code

    Please Login or Register  to view this content.




    Option 2

    Store your data in an array

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 08-16-2019 at 05:35 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    06-20-2019
    Location
    Minnesota
    MS-Off Ver
    Office 2019
    Posts
    39

    Re: Condesning/Automating Nested If statements

    I suppose that what I would prefer to do is be able to have the "passwords" come from a list in column Q, and search for that same password in column B. Then, if the password they entered is in B, it will make all the rows that have it visible. This way I won't have to manually enter the passwords and choose the new rows for them to reveal if I end up changing the passwords/ranges at all in the future.

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    Hi !

    With this column Q you may use an advanced filter to create the unique passwords list
    and with the worksheet MATCH function or Range.Find method in order to check a password
    then filter the rows (or just directly filter the rows accordingly).

    With a workbook sample and a clear & complete explanation it would be easier for helpers …

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Condesning/Automating Nested If statements

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    06-20-2019
    Location
    Minnesota
    MS-Off Ver
    Office 2019
    Posts
    39

    Re: Condesning/Automating Nested If statements

    This is very helpful for condensing it, but is there a way that I am able to use cell references for the passwords? Then use those passwords to check against column B and unhide any rows where the password shows up in column B?

+ 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. Formula with nested IF statements & AND statements
    By Hollywood44 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-11-2018, 03:38 PM
  2. [SOLVED] Nested if statements containing multiple and statements
    By John M. in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-22-2014, 11:48 PM
  3. questions with if statements and nested if statements
    By Pat Excel in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 02-03-2013, 01:41 PM
  4. Nested if statements with AND and OR statements
    By joeljoel in forum Excel General
    Replies: 4
    Last Post: 08-08-2011, 12:57 PM
  5. Multiple nested IF statements and AND statements
    By TonyGetz in forum Excel General
    Replies: 2
    Last Post: 12-14-2010, 03:07 AM
  6. Nested If statements / logic statements
    By Brainless_09 in forum Excel General
    Replies: 3
    Last Post: 06-17-2009, 02:59 PM
  7. Replies: 12
    Last Post: 05-15-2009, 08:38 AM

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