+ Reply to Thread
Results 1 to 5 of 5

Shortening Coding in IF-statements

  1. #1
    Forum Contributor
    Join Date
    08-19-2009
    Location
    Netherlands, Amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    585

    Shortening Coding in IF-statements

    Hello all,

    lets say that before a long part of code I first want to test something (part1) if necessary then (part1b) and then proceed with (part2)
    if not necessary then (part2) skipping (part1b)


    IF part1 THEN part1b & part2
    ELSE
    part2


    If part 2 is lengthy the code will be very long.
    Is there a better way?
    Last edited by Jonathan78; 09-05-2011 at 02:53 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    06-19-2010
    Location
    Holywell, N Wales, UK
    MS-Off Ver
    Excel 2013
    Posts
    470

    Re: Shortening Coding in IF-statements

    Hi Jonathan78
    Could you define part2 in a separate sub()?
    Your main code could then be something like:
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    08-19-2009
    Location
    Netherlands, Amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    585

    Re: Shortening Coding in IF-statements

    Thank you Barry, great solution!

  4. #4
    Valued Forum Contributor
    Join Date
    06-19-2010
    Location
    Holywell, N Wales, UK
    MS-Off Ver
    Excel 2013
    Posts
    470

    Re: Shortening Coding in IF-statements

    OK Jonathan
    Glad it moves you on.
    If you are satisfied please mark your thread as SOLVED.
    Barry

  5. #5
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Shortening Coding in IF-statements

    If you are doing part2 no matter what:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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