PDA

View Full Version : Need help with modifying this array



doctortt
04-18-2011, 06:20 PM
Can someone help me with modifying these codes? How do I make it to do i = i + 3 for array(789) but keeping the rest at i = i + 2?


i = 6
testarray = Array(123, 456, 789)
For Each cell In testarray
Range("b" & i) = cell
i = i + 2
Next

draco664
04-18-2011, 07:04 PM
Can someone help me with modifying these codes? How do I make it to do i = i + 3 for array(789) but keeping the rest at i = i + 2?


i = 6
testarray = Array(123, 456, 789)
For Each cell In testarray
Range("b" & i) = cell
i = i + 2
Next

Try

i = 6
testarray = Array(123, 456, 789)
For Each cell In testarray
If counter = UBound(testarray) Then i = i + 1
Range("b" & i) = cell
i = i + 2
counter = counter + 1
Next

Bob Phillips
04-19-2011, 02:28 AM
For 3 items! Dump the loop



Range("B6").Value = 123
Range("B8").Value = 456
Range("B11").Value = 789