Hello,
I am trying to create a loop that takes data from an array and fills in the range specified with that data.
Here is the code I am having an issue with:
I know it is written improperly, but I can't wrap my head around how it should look, given what I am trying to do.
Works, but it has an issue if I try to add a variable to the starting row of the range. (A1)
Maybe I am just going about this the wrong way...
Full Code:
The idea is to make the first row say blue from column A to column E. Then jump down a row and do the same for red and so on.
Thanks for your time!
I am trying to create a loop that takes data from an array and fills in the range specified with that data.
Here is the code I am having an issue with:
Code:
Range("A" & Cstr(Row1)":E" & CStr(Row1)).Value = lngposition
Code:
Range("A1:E" & CStr(Row1)).Value = lngposition
Maybe I am just going about this the wrong way...
Full Code:
Code:
Sub Color()
Dim Row1 As Integer
Dim Color(0 To 7) As String, lngposition As Long
Color(0) = "Blue"
Color(1) = "Red"
Color(2) = "White"
Color(3) = "Green"
Color(4) = "Purple"
Color(5) = "Orange"
Color(6) = "Yellow"
Color(7) = "Black"
Row1 = 1
For lngposition = LBound(Color) To UBound(Color)
Range("A" & Cstr(Row1)":E" & CStr(Row1)).Value = lngposition
Row1 = Row1.Value + 1
Next lngposition
End Sub
Thanks for your time!