I have several cells on the worksheet that contain a "start" and "end" number value.
They are in groups. Group 1 Start & End, Group 2 Start & End, Group 3 Start & End, etc...
I want to take the series of numbers between the start and end value and separate them with commas, but I want to alternate or pair with the other groups.
Example:
Group 1 Start : 1
Group 1 End: 13
Group 2 Start: 14
Group 2 End: 26
Output: 1,14,2,15,3,16,4,17,5,18,6,19,7,20,8,21,9,22,10,23,11,24,12,25,13,26
Each group should always contain an equal count of numbers in the series.
Code: Select all
Group1Start = Range("B4").Value
Group1End = Range("B5").Value
Group2Start = Range("B8").Value
Group2End = Range("B9").Value
Group3Start = Range("B12").Value
Group3End = Range("B13").Value
Group4Start = Range("B16").Value
Group4End = Range("B17").Value
I learned how to use a For Loop to list the number series in a cell for a single group, but I don't know how to do the alternating:
Code: Select all
Dim i As Integer
Dim List As String
For i = 1 To (Group1End - Group1Start) + 1
List = List & (Group1Start - 1) + i & ","
Next i
'Output results to cell for test
Range("M1").Value = List
Edit: I could also just list the first start and the last end (ex: 1 & 26), and then have the user specify how many groups (ex: 2) since they groups will always have the same count of numbers in the series, then use math to determine the start and end numbers from each group, but I will save that for a later challenge.