Best way to do if else statement

  • Hi,


    I currently have a module in an excel workbook to go to a specific cell date in the header of columns, it also will go to the active row in relation to the matched column header date.


    The question is how can the code be condensed seems if an if else statement can be used, how can the code be made more compact?



    Here's my attempt at an if else statement, seems very long for what looks should be less code



    Works but doesn't look right..

  • Re: Best way to do if else statement


    Hello,


    Let's face it ... if your code is working fine ... it's already quite good ...:wink:


    Without truly analyzing your code ... may be you should take a look at Select Case ...


    Hope this will help

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Re: Best way to do if else statement


    its confusing what you are trying to do... by anyway, wouldnt this be better?


    Its untested, but you get the idea, right?



    By the way, we have a code review forum here just for this kind of thing ;)


    Cheers
    Ger

    _______________________________________________
    There are 10 types of people in the world. Those that understand Binary and those that dont. :P


    Why are Halloween and Christmas the same? Because Oct 31 = Dec 25... ;)

    _______________________________________________

  • Re: Best way to do if else statement


    I'd also probably add an Exit For statement.

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!