#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Stumped

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Stumped

What are you trying to do exactly?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Stumped

Sub test_loop()

For k = 1 To 5

If k < 3 Then
MsgBox k
End If

Next k
End Sub

--
Regards,
Tom Ogilvy


"Andibevan" wrote in message
...
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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" wrote in message
...
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




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default 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
...
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" wrote in message
...
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








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default 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
...
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" wrote in message
...
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







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Stumped

If I try the following I get a Next without For error - Is it possible to
do
something like this?


Hi. You have two "Next" statements, therefore your error. Here are just
two of many ways:

Sub test_loop1()
Dim k As Long
For k = 1 To 5
If k = 3 Then
'Remark: Do Nothing...
Else
MsgBox k
End If
Next k
End Sub


Sub test_loop2()
Dim k As Long
For k = 1 To 5
If k < 3 Then MsgBox k
Next k
End Sub

HTH :)
--
Dana DeLouis
Win XP & Office 2003


"Andibevan" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Still stumped LarryK Excel Worksheet Functions 7 March 30th 09 11:15 AM
Stumped Formula question Excel Discussion (Misc queries) 1 April 16th 08 06:39 PM
Stumped bad, need help please! Kevin Excel Worksheet Functions 10 April 12th 08 10:36 PM
I'm stumped [email protected] Excel Discussion (Misc queries) 0 September 18th 06 09:04 PM
stumped ?? my Excel Worksheet Functions 2 April 13th 06 12:32 PM


All times are GMT +1. The time now is 03:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"