Example post

  • I have the following code that works fine, but it's not very easy to read and I'm sure it can be cut down. The purpose of the code is to calculate sales of stock using a formula and copy any sales >£200 onto another sheet.


  • Re: Example post


    You could try this


  • Re: Example post


    This will be better


  • Re: Example post


    Added comments and explanations to the code


  • Re: Example post


    Can you think of a specific example where .select is necessary?

    _______________________________________________
    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: Example post


    I had a case yesterday where .Select was necessary


    This would not work

    Code
    With Schedule
        .Activate
        With .Shapes("spnWeek")
            .Min = iMin
            .Max = iMax
        End With
        .Columns(1).AutoFit
        Application.GoTo .[a2]
    End With


    I had to use

    Code
    With Schedule
        .Activate
        .Shapes("spnWeek").Select
        With Selection
            .Min = iMin
            .Max = iMax
        End With
        .Columns(1).AutoFit
        Application.GoTo .[a2]
    End With


    The shape is a Spin Button, iMin and iMax are minimum and maximum WEEKNUMBER for a range of dates.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: Example post


    Thanks KJ, ya that rings a bell alright... seem to remember getting caught out with something similar in the past. Good example.


    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... ;)

    _______________________________________________

Participate now!

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