I'm new to Visual Basic and have spent all day troubleshooting. I would greatly appreciate your expertise!! Truly.
Goal:
1) Randomly generate 10 different green cells within Range("A7:Y7")
2) Number those green cells 1 to 10, from right to left.
3) Set up an array that holds a randomly generated speed (from 1 to 5) for each green cell.
Module should be executable using a keystroke shortcut (not included here, but I made a macro that executes the module using keystrokes ctrl+g)
Here is what I've got :
Dim iColumn As Integer
Dim lowerBound As Integer
Dim upperBound As Integer
Dim lowerSpeed As Integer
Dim upperSpeed As Integer
Dim iVehicles() As Integer
Dim iSpeed() As Integer
Dim counter As Integer
lowerBound = 1
upperBound = 25
lowerSpeed = 1
upperSpeed = 5
Cells.Clear
Do Until counter = 10
iColumn = Int((upperBound - lowerBound + 1) * Rnd() + lowerBound)
'iSpeed(i) = Int((upperSpeed- lowerSpeed + 1) * Rnd() + lowerSpeed)
'Cells.Clear
Worksheets("sheet1").Cells(7, iColumn).Interior.Color = RGB(0, 300, 0)
'Worksheets("sheet1").Cells(7, iColumn).Value = i
For Each c In Worksheets("Sheet1").Range("A7:Y7").Cells
If c.Interior.Color = RGB(0, 300, 0) Then
counter = counter + 1
End If
Next
Loop
j = 10
For i = 25 To 1
If ActiveSheet.Cells(7, i).Interior.Color = RGB(0, 300, 0) Then
Cells(7, i).Value = j
j = j - 1
Else
i = i - 1
End If
Next
End Sub