Hi Everyone,
I have this loop I'm building and there's one part (highlighted blue) where it takes all cells with the color index of 46 and places their values in this cell Sheets(1).Cells(2, 81).Value. At the moment each one overwrites the previous. What I'm looking for is for the text to accumulate in that cell separated by a comma for each new addition
Thanks,
Jordan
I have this loop I'm building and there's one part (highlighted blue) where it takes all cells with the color index of 46 and places their values in this cell Sheets(1).Cells(2, 81).Value. At the moment each one overwrites the previous. What I'm looking for is for the text to accumulate in that cell separated by a comma for each new addition
Code:
Sub TestCode()
Dim iCell As Range, ws As Worksheet
Set ws = Sheet6
Lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
For Each iCell In Range("A2:CA30")
With iCell
If iCell.Interior.ColorIndex = 35 Then
ws.Cells(Lastrow + 1, 1).Value = iCell.Value
ws.Cells(Lastrow + 1, 1).Offset(0, 1).Value = iCell.Offset(0, 1).Value
Lastrow = Lastrow + 1
ElseIf iCell.Value <> "" And iCell.Interior.ColorIndex = 3 Then
ws.Cells(Lastrow + 1, 3).Value = Sheets(1).Cells(1, iCell.Column).Value
ws.Cells(Lastrow + 1, 10).Value = iCell.Value
Lastrow = Lastrow + 1
ElseIf iCell.Value <> "" And iCell.Interior.ColorIndex = 24 Then
ws.Cells(Lastrow + 1, 3).Value = Sheets(1).Cells(1, iCell.Column).Value
ws.Cells(Lastrow + 1, 6).Value = iCell.Value
ws.Cells(Lastrow + 1, 8).Value = iCell.Offset(0, 1).Value
Lastrow = Lastrow + 1
ElseIf iCell.Value > "0" And iCell.Interior.ColorIndex = 40 Then
ws.Cells(Lastrow + 1, 8).Value = Sheets(1).Cells(1, iCell.Column).Value
ws.Cells(Lastrow + 1, 10).Value = iCell.Value
Lastrow = Lastrow + 1
[COLOR=#0000ff] ElseIf iCell.Value > "0" And iCell.Interior.ColorIndex = 46 Then[/COLOR]
[COLOR=#0000ff] Sheets(1).Cells(2, 81).Value = Sheets(1).Cells(1, iCell.Column).Value[/COLOR]
ElseIf iCell.Value > "0" And iCell.Interior.ColorIndex = 48 Then
ws.Cells(Lastrow + 1, 8).Value = Sheets(1).Cells(1, iCell.Column).Value
ws.Cells(Lastrow + 1, 10).Value = iCell.Offset(0, 1).Value
Lastrow = Lastrow + 1
End If[COLOR=#00ffff][/COLOR][COLOR=#40e0d0][/COLOR]
End With
Next iCell
End Sub
Thanks,
Jordan