Simple Procedure Edit

Posted on 2014-08-13
Last Modified: 2014-08-16
The following code, selects the next 500 lines and runs the code.

Sub MakeSIF_FromNext500Rows()
    Range(ActiveCell, ActiveCell.Offset(499, 0)).Copy
    Sheets("Order Line Items").Select
    Application.Run "CU50BySalesOrder.xlsm!insert_mktg_prog"
    Sheets("Order Line Items").Select
    Call ClearResetSIFSheet
    ActiveCell.Offset(500, 0).Select
End Sub

Open in new window

How do you chg this so it would work on whatever cells are pre-selected?  Need to chg Ln3 and Ln11
Please advise and thanks.
Question by:RWayneH
    LVL 20

    Accepted Solution

    Change line 3 to Selection.Copy, and the pre-selected cells will be used.

    What do you want to happen in line 11, when the cells are pre-selected.
    LVL 27

    Expert Comment

    by:Glenn Ray
    No points, but agreeing with Ejgil on line 3 change.  As for Line 11, it's really no longer necessary.  However, if you wanted the user's active cell to move to the next cell after the active selection (like it did above), you could change line 11 to:
    ActiveCell.Offset(Selection.Rows.Count, 0).Select

    Open in new window


    Author Closing Comment

    Thanks for the help.  I cannot believe I did not figure that out...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
    Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
    This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
    This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    6 Experts available now in Live!

    Get 1:1 Help Now