Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you use "except" in a for next loop
I have some code that loops through some records:
For j = 100 To 144 Step 1 num = "" If Len(Trim(arr(j))) = 0 Then num = j arr(num) = "PK" Exit For What if I want to make an exception, what if 119 does not exist, fo example, how do you exclude specific numbers from this statement. Thank -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you use "except" in a for next loop
Try something like this:
Dim arr(100 To 144) For j = 100 To 144 Step 1 num = "" Select Case j Case Is = 119 'do nothing ' MsgBox "119" Case Else If Len(Trim(arr(j))) = 0 Then num = j arr(num) = "PK" Exit For End If End Select Next 'j Regards Trevor "hotherps " wrote in message ... I have some code that loops through some records: For j = 100 To 144 Step 1 num = "" If Len(Trim(arr(j))) = 0 Then num = j arr(num) = "PK" Exit For What if I want to make an exception, what if 119 does not exist, for example, how do you exclude specific numbers from this statement. Thanks --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you use "except" in a for next loop
|
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you use "except" in a for next loop
Post the full routine; I had to make it up and I've obviously guessed wrong
"hotherps " wrote in message ... I keep getting a "next without for" error? --- Message posted from http://www.ExcelForum.com/ |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you use "except" in a for next loop
Thanks Trevor that worked great.
Now a really dumb question, what if I have to exclude more than on value? (I probably should have mentioned that the first time, sorry. let's say 135,137,139 for exampl -- Message posted from http://www.ExcelForum.com |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you use "except" in a for next loop
Case Is = 119,135,137,139 'do nothing
Regards Trevor "hotherps " wrote in message ... Thanks Trevor that worked great. Now a really dumb question, what if I have to exclude more than one value? (I probably should have mentioned that the first time, sorry. let's say 135,137,139 for example --- Message posted from http://www.ExcelForum.com/ |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you use "except" in a for next loop
'-----------------------------------------------
For j = 100 To 144 If j < 119 Then ........ '------------------------------------------------ Don't need Step 1 which is the default -- Message posted from http://www.ExcelForum.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
change "true" and "false" to "availble" and "out of stock" | Excel Worksheet Functions | |||
change increasment in a "for" loop | Excel Discussion (Misc queries) | |||
HELP on "left","right","find","len","substitute" functions | Excel Discussion (Misc queries) | |||
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next | New Users to Excel |