+ Reply to Thread
Results 1 to 9 of 9

Vba assistance to simplify code

  1. #1
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,170

    Vba assistance to simplify code

    Hi All

    I have started a new thread as the requirements have changed. Can anyone please assist in the simplification of the below code. It is the saving and re-call of a userform containing check boxes.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Vba assistance to simplify code

    How's this for starters?

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,170

    Re: Vba assistance to simplify code

    Nope, right over my head.....
    bakerman2....don't understand that at all.
    It works very well but have never seen it before. Perhaps a link to broaden my mind lol

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Vba assistance to simplify code

    Returns one of two parts, depending on the evaluation of an expression.

    You can use IIf anywhere you can use expressions. You use IIf to determine if another expression is true or false. If the expression is true, IIf returns one value; if it is false, IIf returns another. You specify the values IIf returns.

    See some examples

    Syntax

    IIf ( expr , truepart , falsepart )

    The IIf function syntax has these arguments:

    Argument

    Description

    expr

    Required. Expression you want to evaluate.

    truepart

    Required. Value or expression returned if expr is True.

    falsepart

    Required. Value or expression returned if expr is False.


    Remarks

    IIf always evaluates both truepart and falsepart, even though it returns only one of them. Because of this, you should watch for undesirable side effects. For example, if evaluating falsepart results in a division by zero error, an error occurs even if expr is True.

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,170

    Re: Vba assistance to simplify code

    Wow, that is new to me. Thanks bakerman2 for your assistance and tutorial.
    Don't suppose the IIf could work for the Userform_Initializing code

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,170

    Re: Vba assistance to simplify code

    Hi All

    For those of you who have never seen this before....like me

    Found following link using IIf
    https://support.office.com/en-us/art...0-647539c764e3

  7. #7
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Vba assistance to simplify code

    different approach using loops and old standard if
    Attached Files Attached Files
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,170

    Re: Vba assistance to simplify code

    Thanks humdingaling

    That works like a charm.

  9. #9
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Vba assistance to simplify code

    You're welcome and thanks for adding rep points.

+ 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. [SOLVED] please simplify the code
    By kprabhupaul in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-14-2016, 02:16 AM
  2. [SOLVED] simplify code VBA
    By nizar2016 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-10-2016, 10:48 AM
  3. [SOLVED] simplify vba code
    By wyldjokre69 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-11-2014, 10:01 AM
  4. Simplify my Code
    By wrathastorm in forum Excel - New Users/Basics
    Replies: 6
    Last Post: 04-26-2012, 02:23 PM
  5. hi can anyone simplify this old bit of code
    By khalid79m in forum Excel General
    Replies: 3
    Last Post: 12-28-2006, 01:04 PM
  6. Simplify this code
    By Scott in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-08-2006, 12:00 AM
  7. [SOLVED] simplify code
    By matt in forum Excel General
    Replies: 3
    Last Post: 09-28-2005, 07: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