+ Reply to Thread
Results 1 to 3 of 3

nested loops

Hybrid View

  1. #1
    jer
    Guest

    nested loops

    Some help please
    when I try to run the following code I am getting "Loop without Do"

    Dim cell As Range, odate As Date, ndate As Date
    Set cell = ActiveWorkbook.Worksheets("Working Sample (3)").Cells(3, 2)

    Do Until IsEmpty(cell.Value)

    Do While cell = cell.Offset(-1, 0)
    odate = cell.Offset(-1, 11).Value
    ndate = cell.Offset(0, 11).Value
    ndate = odate
    If cell.Offset(0, 9) = "Y" Then
    ndate = DateAdd("y", 1, odate)
    If cell.Offset(0, 9) = "Q" Then
    ndate = DateAdd("m", 3, odate)
    End If
    Set cell = cell.Offset(1, 0)
    Loop
    Set cell = cell.Offset(1, 0)
    Loop
    I am attempting to schedul payments based on frequency, Y = Annually and Q =
    quarterly. Using the first payment date for a name in column 2, I am
    attempting to schedule payment dates by frequency

    col 2 col 11 col 13
    1 $120.00 Y 9/30/2006
    1 $100.00 Y 9/30/2006
    1 $200.00 Y 9/30/2006
    1 $300.00 Y 9/30/2006
    1 $150.00 Y 9/30/2006

    --
    thanks as always for the help

  2. #2
    Bob Umlas
    Guest

    Re: nested loops

    You have 2 if-statements, and only one End If.
    Bob Umlas

    "jer" <jearl45@hotmail.com> wrote in message
    news:263198B3-4535-43D4-A7AD-3A7088A51247@microsoft.com...
    > Some help please
    > when I try to run the following code I am getting "Loop without Do"
    >
    > Dim cell As Range, odate As Date, ndate As Date
    > Set cell = ActiveWorkbook.Worksheets("Working Sample (3)").Cells(3, 2)
    >
    > Do Until IsEmpty(cell.Value)
    >
    > Do While cell = cell.Offset(-1, 0)
    > odate = cell.Offset(-1, 11).Value
    > ndate = cell.Offset(0, 11).Value
    > ndate = odate
    > If cell.Offset(0, 9) = "Y" Then
    > ndate = DateAdd("y", 1, odate)
    > If cell.Offset(0, 9) = "Q" Then
    > ndate = DateAdd("m", 3, odate)
    > End If
    > Set cell = cell.Offset(1, 0)
    > Loop
    > Set cell = cell.Offset(1, 0)
    > Loop
    > I am attempting to schedul payments based on frequency, Y = Annually and Q
    > =
    > quarterly. Using the first payment date for a name in column 2, I am
    > attempting to schedule payment dates by frequency
    >
    > col 2 col 11 col 13
    > 1 $120.00 Y 9/30/2006
    > 1 $100.00 Y 9/30/2006
    > 1 $200.00 Y 9/30/2006
    > 1 $300.00 Y 9/30/2006
    > 1 $150.00 Y 9/30/2006
    >
    > --
    > thanks as always for the help




  3. #3
    jer
    Guest

    Re: nested loops

    Thanks Bob ... found out after I posted ...
    --
    thanks as always for the help


    "Bob Umlas" wrote:

    > You have 2 if-statements, and only one End If.
    > Bob Umlas
    >
    > "jer" <jearl45@hotmail.com> wrote in message
    > news:263198B3-4535-43D4-A7AD-3A7088A51247@microsoft.com...
    > > Some help please
    > > when I try to run the following code I am getting "Loop without Do"
    > >
    > > Dim cell As Range, odate As Date, ndate As Date
    > > Set cell = ActiveWorkbook.Worksheets("Working Sample (3)").Cells(3, 2)
    > >
    > > Do Until IsEmpty(cell.Value)
    > >
    > > Do While cell = cell.Offset(-1, 0)
    > > odate = cell.Offset(-1, 11).Value
    > > ndate = cell.Offset(0, 11).Value
    > > ndate = odate
    > > If cell.Offset(0, 9) = "Y" Then
    > > ndate = DateAdd("y", 1, odate)
    > > If cell.Offset(0, 9) = "Q" Then
    > > ndate = DateAdd("m", 3, odate)
    > > End If
    > > Set cell = cell.Offset(1, 0)
    > > Loop
    > > Set cell = cell.Offset(1, 0)
    > > Loop
    > > I am attempting to schedul payments based on frequency, Y = Annually and Q
    > > =
    > > quarterly. Using the first payment date for a name in column 2, I am
    > > attempting to schedule payment dates by frequency
    > >
    > > col 2 col 11 col 13
    > > 1 $120.00 Y 9/30/2006
    > > 1 $100.00 Y 9/30/2006
    > > 1 $200.00 Y 9/30/2006
    > > 1 $300.00 Y 9/30/2006
    > > 1 $150.00 Y 9/30/2006
    > >
    > > --
    > > thanks as always for the help

    >
    >
    >


+ 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