+ Reply to Thread
Results 1 to 7 of 7

Consolidating Code

  1. #1
    Excel User
    Guest

    Consolidating Code

    How can I consolidate the following code so that it improves execution time?
    I recorded "scrolling" in my macro, and I'd like to consolidate every
    discreet line/column scroll command.

    ActiveWindow.ScrollColumn = 5
    ActiveWindow.ScrollColumn = 4
    ActiveWindow.ScrollColumn = 3
    ActiveWindow.ScrollColumn = 2
    ActiveWindow.ScrollColumn = 1
    ActiveWindow.ScrollRow = 5
    ActiveWindow.ScrollRow = 2
    ActiveWindow.ScrollRow = 1

    ....so that it resembles something like this:
    "ActiveWindow.ScrollColumn = 4:1"
    "ActiveWindow.ScrollRow = 5:1"

    Thanks you.

  2. #2
    Forum Contributor
    Join Date
    11-16-2004
    Posts
    282
    Try this instead:

    ActiveWindow.ScrollColumn = 1
    ActiveWindow.ScrollRow = 1


    Hope this helps,
    theDude

  3. #3
    ben
    Guest

    RE: Consolidating Code

    only the last command in each set counts

    scrollcolumn automatically puts what ever column number you put as the
    leftmost column, it is not a series of scrolls added together
    ActiveWindow.ScrollColumn = 5
    ActiveWindow.ScrollColumn = 4
    ActiveWindow.ScrollColumn = 3
    ActiveWindow.ScrollColumn = 2
    ActiveWindow.ScrollColumn = 1

    accomplishes the same exact thing as

    activewindow.scrollcolumn = 1



    "Excel User" wrote:

    > How can I consolidate the following code so that it improves execution time?
    > I recorded "scrolling" in my macro, and I'd like to consolidate every
    > discreet line/column scroll command.
    >
    > ActiveWindow.ScrollColumn = 5
    > ActiveWindow.ScrollColumn = 4
    > ActiveWindow.ScrollColumn = 3
    > ActiveWindow.ScrollColumn = 2
    > ActiveWindow.ScrollColumn = 1
    > ActiveWindow.ScrollRow = 5
    > ActiveWindow.ScrollRow = 2
    > ActiveWindow.ScrollRow = 1
    >
    > ...so that it resembles something like this:
    > "ActiveWindow.ScrollColumn = 4:1"
    > "ActiveWindow.ScrollRow = 5:1"
    >
    > Thanks you.


  4. #4
    Chip
    Guest

    Re: Consolidating Code

    Seeing as how all that code does it put you back at your original view,
    why do you need the code at all?


  5. #5
    Excel User
    Guest

    Re: Consolidating Code

    Thanks - and good question: The page is a switchboard, and I want to keep it
    "clean" and have the page reset with a selected cell out of view every time
    it's unhidden.

    "Chip" wrote:

    > Seeing as how all that code does it put you back at your original view,
    > why do you need the code at all?
    >
    >


  6. #6
    Excel User
    Guest

    RE: Consolidating Code

    Thanks--I greatly appreciate your help.
    Regards.
    EU

    "ben" wrote:

    > only the last command in each set counts
    >
    > scrollcolumn automatically puts what ever column number you put as the
    > leftmost column, it is not a series of scrolls added together
    > ActiveWindow.ScrollColumn = 5
    > ActiveWindow.ScrollColumn = 4
    > ActiveWindow.ScrollColumn = 3
    > ActiveWindow.ScrollColumn = 2
    > ActiveWindow.ScrollColumn = 1
    >
    > accomplishes the same exact thing as
    >
    > activewindow.scrollcolumn = 1
    >
    >
    >
    > "Excel User" wrote:
    >
    > > How can I consolidate the following code so that it improves execution time?
    > > I recorded "scrolling" in my macro, and I'd like to consolidate every
    > > discreet line/column scroll command.
    > >
    > > ActiveWindow.ScrollColumn = 5
    > > ActiveWindow.ScrollColumn = 4
    > > ActiveWindow.ScrollColumn = 3
    > > ActiveWindow.ScrollColumn = 2
    > > ActiveWindow.ScrollColumn = 1
    > > ActiveWindow.ScrollRow = 5
    > > ActiveWindow.ScrollRow = 2
    > > ActiveWindow.ScrollRow = 1
    > >
    > > ...so that it resembles something like this:
    > > "ActiveWindow.ScrollColumn = 4:1"
    > > "ActiveWindow.ScrollRow = 5:1"
    > >
    > > Thanks you.


  7. #7
    Chip
    Guest

    Re: Consolidating Code

    I am not sure I understand your comment, so do you want the view to
    reset on the selected cell? If so, use this:

    Range("J1").Select
    ActiveWindow.ScrollColumn = ActiveCell.Column
    ActiveWindow.ScrollRow = ActiveCell.Row
    With J1 being the Cell you want selected/viewed


+ 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