+ Reply to Thread
Results 1 to 4 of 4

So close! Problems with Loop

  1. #1
    Linking to specific cells in p
    Guest

    So close! Problems with Loop

    Hi - I'm almost there! For some reason, the loop I wrote stops before it
    should (it should stop when variable x = variable z). Can someone take a
    look and let me know if they think they know why? The loop starts half way
    down -- I put in the code for the whole Macro as it may help you understand
    what I'm doing here. Any help is appreciated!!

    Sub Macro1()
    '
    ' Macro1 Macro
    ' Macro recorded 1/23/2005 by Cisco Systems, Inc.
    '

    '
    Dim x As Range
    Dim y As Range
    Dim z As Range
    Dim Myrange As Range

    Worksheets("Aurora").Activate
    Range("A1").Select

    Cells.Find(What:="MAX PRICE AFTER ADJUSTMENTS:", After:=ActiveCell,
    LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate

    Set x = ActiveWindow.RangeSelection
    Set y = ActiveCell.Offset(0, 1)
    Set z = ActiveCell.Offset(0, 1)

    ActiveCell.Offset(1, 1).Range("A1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Set Myrange = ActiveWindow.RangeSelection

    For Each c In Myrange
    c.Value = c.Value / 500
    Next


    Do While x <> z

    y.Select

    Cells.Find(What:="MAX PRICE AFTER ADJUSTMENTS:", After:=ActiveCell,
    LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate

    Set z = ActiveWindow.RangeSelection
    Set y = ActiveCell.Offset(0, 1)

    ActiveCell.Offset(1, 1).Range("A1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Set Myrange = ActiveWindow.RangeSelection

    For Each c In Myrange
    c.Value = c.Value / 500
    Next
    Loop

    End Sub

  2. #2
    PaulD
    Guest

    Re: So close! Problems with Loop


    "Linking to specific cells in pivot table"
    <[email protected]> wrote in
    message news:[email protected]...
    : Hi - I'm almost there! For some reason, the loop I wrote stops before it
    : should (it should stop when variable x = variable z). Can someone take a
    : look and let me know if they think they know why? The loop starts half
    way
    : down -- I put in the code for the whole Macro as it may help you
    understand
    : what I'm doing here. Any help is appreciated!!
    :
    <snip>:

    : Do While x <> z

    have you tried Do Until x = z
    did you verify what x and z were when the loop ended?

    Paul D



  3. #3
    Linking to specific cells in pivot table
    Guest

    Re: So close! Problems with Loop

    Thanks Paul. How do I verify what x and z are when the loop ends?

    "PaulD" wrote:

    >
    > "Linking to specific cells in pivot table"
    > <[email protected]> wrote in
    > message news:[email protected]...
    > : Hi - I'm almost there! For some reason, the loop I wrote stops before it
    > : should (it should stop when variable x = variable z). Can someone take a
    > : look and let me know if they think they know why? The loop starts half
    > way
    > : down -- I put in the code for the whole Macro as it may help you
    > understand
    > : what I'm doing here. Any help is appreciated!!
    > :
    > <snip>:
    >
    > : Do While x <> z
    >
    > have you tried Do Until x = z
    > did you verify what x and z were when the loop ended?
    >
    > Paul D
    >
    >
    >


  4. #4
    PaulD
    Guest

    Re: So close! Problems with Loop


    "Linking to specific cells in pivot table"
    <[email protected]> wrote in
    message news:[email protected]...
    : Thanks Paul. How do I verify what x and z are when the loop ends?
    :

    one way is to use a breakpoint at the end of the loop then look at the value
    for each

    Paul D



+ 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