+ Reply to Thread
Results 1 to 5 of 5

"Loop until" syntax question

  1. #1
    Registered User
    Join Date
    08-26-2005
    Posts
    16

    "Loop until" syntax question

    Hi,
    I am after help for the following:

    Range("TotalCentralregion").Select ' Range is a single cell
    Selection.Offset(1, 0).Select
    Selection.Formula = "=(" & ActiveCell.Offset(0, -2).Address & " /EastTotal)"

    What I need to do is loop this formula down a column until it gets to a single cell that has been named "TotalEastRegion". (Formula has to include "TotaleastRegion).

    Thanks for the help in advance.

    Fastbike
    Last edited by Fastbike; 09-02-2005 at 12:32 PM.

  2. #2
    Jim Rech
    Guest

    Re: "Loop until" syntax question

    This really isn't a need to do any looping (or selecting):

    Sub demo()
    With Range(Range("TotalCentralRegion").Offset(1), "TotalEastRegion")
    .FormulaR1C1 = "=RC[-2]/EastTotal"
    End With
    End Sub

    --
    Jim
    "Fastbike" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi,
    > I am after help for the following:
    >
    > Range("TotalCentralregion").Select ' Range is a single cell
    > Selection.Offset(1, 0).Select
    > Selection.Formula = "=(" & ActiveCell.Offset(0, -2).Address & "
    > /EastTotal)"
    >
    > What I need to do is loop this formula down a column until it gets to a
    > single cell that has been named "TotalEastRegion". (Formula has to
    > include "TotaleastRegion).
    >
    > Thanks for the help in advance.
    >
    > Fastbike
    >
    >
    > --
    > Fastbike
    > ------------------------------------------------------------------------
    > Fastbike's Profile:
    > http://www.excelforum.com/member.php...o&userid=26701
    > View this thread: http://www.excelforum.com/showthread...hreadid=401530
    >




  3. #3
    Jim Thomlinson
    Guest

    RE: "Loop until" syntax question

    The easiest way is to create a Range which is all of the cells between the
    two named ranges and then ust traverse those cells... Kind of like this

    dim rngToSearch as Range
    dim rngCurrent as range

    set rngToSearch = range(Range("TotalCentralregion"), Range("TotalEastregion"))
    for each rngCurrent in rngToSearch
    'rngCurrent is just like the active cell
    rngCurrent.Formula = "=(" & rngCurrent.Offset(0, -2).Address & "/EastTotal)"

    next rngCurrent
    --
    HTH...

    Jim Thomlinson


    "Fastbike" wrote:

    >
    > Hi,
    > I am after help for the following:
    >
    > Range("TotalCentralregion").Select ' Range is a single cell
    > Selection.Offset(1, 0).Select
    > Selection.Formula = "=(" & ActiveCell.Offset(0, -2).Address & "
    > /EastTotal)"
    >
    > What I need to do is loop this formula down a column until it gets to a
    > single cell that has been named "TotalEastRegion". (Formula has to
    > include "TotaleastRegion).
    >
    > Thanks for the help in advance.
    >
    > Fastbike
    >
    >
    > --
    > Fastbike
    > ------------------------------------------------------------------------
    > Fastbike's Profile: http://www.excelforum.com/member.php...o&userid=26701
    > View this thread: http://www.excelforum.com/showthread...hreadid=401530
    >
    >


  4. #4
    Bob Phillips
    Guest

    Re: "Loop until" syntax question


    Range("TotalCentralregion").select
    Do
    Selection.(1, 0).Formula = "=(" & ActiveCell.Offset(0, -2).Address &
    "/EastTotal)"
    ACtivecell.Offset(1.0).select
    Loop Until Activecell.value like "*TotalEastRegion*"

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Fastbike" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi,
    > I am after help for the following:
    >
    > Range("TotalCentralregion").Select ' Range is a single cell
    > Selection.Offset(1, 0).Select
    > Selection.Formula = "=(" & ActiveCell.Offset(0, -2).Address & "
    > /EastTotal)"
    >
    > What I need to do is loop this formula down a column until it gets to a
    > single cell that has been named "TotalEastRegion". (Formula has to
    > include "TotaleastRegion).
    >
    > Thanks for the help in advance.
    >
    > Fastbike
    >
    >
    > --
    > Fastbike
    > ------------------------------------------------------------------------
    > Fastbike's Profile:

    http://www.excelforum.com/member.php...o&userid=26701
    > View this thread: http://www.excelforum.com/showthread...hreadid=401530
    >




  5. #5
    Registered User
    Join Date
    08-26-2005
    Posts
    16
    Hi,
    thanks for all the replies. Much appreciated.

+ 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