LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Increment through For Next loop

I have this piece of code that assigns numbers to locations. One i
called "Pack" and the other "Ice". Pack has locations 100-145
Ice locations are 124 - 138 (increment by 2).

If Ice is not needed, the code should assign everything to "Pack"
which it does but, In that scenario the incremented numbers are bein
used twice. That can not happen, if a location is used in Ice it need
to be unavailable to Pack, how do I stop the duplicates.
Here is the code and a small example of what it looks like:
i = 100
For Each cell In Range("A1:DD2567")
If cell.Value = "Pack" Then
i = i + 1
For j = 0 To 8
cell.Offset(0, j).Value = "Pack" & CStr(i)
Next j
If i 145 Then i = 100
End If
Next cell

i = 112
For Each cell In Range("A1:DD2567")

If cell.Value = "Ice" Then
i = i + 2
For j = 0 To 8
cell.Offset(0, j).Value = "Ice" & CStr(i)
Next j
If i 136 Then i = 112
End If
Next cell

Pack101 Pack101 Pack101 Pack101 Pack101 Pack101
Pack102 Pack102 Pack102 Pack102 Pack102 Pack102

Pack103 Pack103 Pack103 Pack103 Pack103 Pack103
Pack Pack104 Pack104 Pack104 Pack104 Pack104
Ice114 Ice114 Ice114 Ice114 Ice114 Ice114
Ice116 Ice116 Ice116 Ice116 Ice116 Ice116
Pack Pack105 Pack105 Pack105 Pack105 Pack105
Pack Pack106 Pack106 Pack106 Pack106 Pack106

When Pack gets up to 114 It will assign it to Pack, but it has alread
been assigned to Ice. So it should skip that number.
Thank

--
Message posted from http://www.ExcelForum.com

 
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
Find loop doesn't loop JSnow Excel Discussion (Misc queries) 2 June 24th 09 08:28 PM
Increment Maria Excel Worksheet Functions 4 November 9th 07 12:10 AM
How to increment within For Next Loop EagleOne Excel Discussion (Misc queries) 1 August 9th 06 04:18 PM
Worksheet_Change - loop within a loop bgm Excel Programming 1 January 19th 04 01:27 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 02:53 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"