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?

    Check out our new reputation system. Click on the Like button under the post!
    _______________________________________________

    [SIZE=8px]There are 10 types of people in the world. Those that understand Binary and those that dont.


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


    The BEST Lookup function of all time


    Dynamic Named Ranges are your bestest friend[/SIZE]
    _______________________________________________

  • Re: Example post


    I had a case yesterday where .Select was necessary


    This would not work

    Code
    1. With Schedule
    2. .Activate
    3. With .Shapes("spnWeek")
    4. .Min = iMin
    5. .Max = iMax
    6. End With
    7. .Columns(1).AutoFit
    8. Application.GoTo .[a2]
    9. End With


    I had to use

    Code
    1. With Schedule
    2. .Activate
    3. .Shapes("spnWeek").Select
    4. With Selection
    5. .Min = iMin
    6. .Max = iMax
    7. End With
    8. .Columns(1).AutoFit
    9. Application.GoTo .[a2]
    10. 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

    Check out our new reputation system. Click on the Like button under the post!
    _______________________________________________

    [SIZE=8px]There are 10 types of people in the world. Those that understand Binary and those that dont.


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


    The BEST Lookup function of all time


    Dynamic Named Ranges are your bestest friend[/SIZE]
    _______________________________________________