+ Reply to Thread
Results 1 to 7 of 7

Stumped

Hybrid View

Guest Stumped 12-21-2005, 02:25 PM
Guest Re: Stumped 12-21-2005, 02:35 PM
Guest Re: Stumped 12-21-2005, 02:45 PM
Guest Re: Stumped 12-21-2005, 11:15 PM
Guest Re: Stumped 12-22-2005, 12:25 PM
Guest Re: Stumped 12-22-2005, 03:20 PM
Guest Re: Stumped 12-23-2005, 11:10 AM
  1. #1
    Gary Keramidas
    Guest

    Re: Stumped

    this will even skip 3, but don't know what you're trying to accomplish

    Sub test_loop()
    Dim k As Long
    For k = 1 To 5

    If k = 3 Then
    'do nothing
    Else
    MsgBox k
    End If

    Next k
    End Sub


    --


    Gary


    "Andibevan" <Andibevan@notehere-hotmail.com> wrote in message
    news:%23I9sprlBGHA.3064@TK2MSFTNGP10.phx.gbl...
    > Hi,
    >
    > If I try the following I get a Next without For error - Is it possible to
    > do
    > something like this?
    >
    >
    > Sub test_loop()
    >
    > For k = 1 To 5
    >
    > If k = 3 Then
    > Next k
    > Else
    > MsgBox k
    > End If
    >
    > Next k
    > End Sub
    >
    > TIA
    >
    > Andy
    >
    >




  2. #2
    Andibevan
    Guest

    Re: Stumped

    Sorry - I essentially was wondering whether it was possible to include two
    'Next' Statements in one For loop?

    "Gary Keramidas" <GKeramidasATmsn.com> wrote in message
    news:uyaAvUqBGHA.684@tk2msftngp13.phx.gbl...
    > this will even skip 3, but don't know what you're trying to accomplish
    >
    > Sub test_loop()
    > Dim k As Long
    > For k = 1 To 5
    >
    > If k = 3 Then
    > 'do nothing
    > Else
    > MsgBox k
    > End If
    >
    > Next k
    > End Sub
    >
    >
    > --
    >
    >
    > Gary
    >
    >
    > "Andibevan" <Andibevan@notehere-hotmail.com> wrote in message
    > news:%23I9sprlBGHA.3064@TK2MSFTNGP10.phx.gbl...
    > > Hi,
    > >
    > > If I try the following I get a Next without For error - Is it possible

    to
    > > do
    > > something like this?
    > >
    > >
    > > Sub test_loop()
    > >
    > > For k = 1 To 5
    > >
    > > If k = 3 Then
    > > Next k
    > > Else
    > > MsgBox k
    > > End If
    > >
    > > Next k
    > > End Sub
    > >
    > > TIA
    > >
    > > Andy
    > >
    > >

    >
    >




  3. #3
    Dominic
    Guest

    Re: Stumped

    No, it is not.

    It would help to know what you are trying to do, as Kevin O'Neill asked.

    If you are trying to increase k by two through using two next statements,
    then use step 2 in your for loop.

    ex. for k = 1 to 5 step 2




    "Andibevan" wrote:

    > Sorry - I essentially was wondering whether it was possible to include two
    > 'Next' Statements in one For loop?
    >
    > "Gary Keramidas" <GKeramidasATmsn.com> wrote in message
    > news:uyaAvUqBGHA.684@tk2msftngp13.phx.gbl...
    > > this will even skip 3, but don't know what you're trying to accomplish
    > >
    > > Sub test_loop()
    > > Dim k As Long
    > > For k = 1 To 5
    > >
    > > If k = 3 Then
    > > 'do nothing
    > > Else
    > > MsgBox k
    > > End If
    > >
    > > Next k
    > > End Sub
    > >
    > >
    > > --
    > >
    > >
    > > Gary
    > >
    > >
    > > "Andibevan" <Andibevan@notehere-hotmail.com> wrote in message
    > > news:%23I9sprlBGHA.3064@TK2MSFTNGP10.phx.gbl...
    > > > Hi,
    > > >
    > > > If I try the following I get a Next without For error - Is it possible

    > to
    > > > do
    > > > something like this?
    > > >
    > > >
    > > > Sub test_loop()
    > > >
    > > > For k = 1 To 5
    > > >
    > > > If k = 3 Then
    > > > Next k
    > > > Else
    > > > MsgBox k
    > > > End If
    > > >
    > > > Next k
    > > > End Sub
    > > >
    > > > TIA
    > > >
    > > > Andy
    > > >
    > > >

    > >
    > >

    >
    >
    >


+ 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