Hi, I have a sheet with some green colored cells and I'd like to change their borders. The numbers of green cells that need to be changed is identified based to another cell's value.
For each row, I need to find the first green cell from right to left and then add as many red borders as the number in the Value2 column.
Then, I need to find the next green cell to the left (after the cells with borders placed from value2), and add as many red borders as the number in the Value1 column.
In the example table above, the upper section shows the data that I currently have. The lower section is what I need to have after adding the borders with vba.
The numbers in columns for Value1 and Value2 are changing, they are not always the same. Also, the number of the green cells are not always the same.
I don't know how to find and select the cells to apply to code, but I know how to add the borders. I am using this code:
Any ideas would be most appreciated!!!
For each row, I need to find the first green cell from right to left and then add as many red borders as the number in the Value2 column.
Then, I need to find the next green cell to the left (after the cells with borders placed from value2), and add as many red borders as the number in the Value1 column.
In the example table above, the upper section shows the data that I currently have. The lower section is what I need to have after adding the borders with vba.
The numbers in columns for Value1 and Value2 are changing, they are not always the same. Also, the number of the green cells are not always the same.
I don't know how to find and select the cells to apply to code, but I know how to add the borders. I am using this code:
VBA Code:
Sub Add_Borders()
Range("K15, I15, G15").Select
With Selection.Borders
.LineStyle = XlLineStyle.xlContinuous
.Weight = xlMedium
.Color = RGB(255, 0, 0)
End With
With Selection.Borders(xlDiagonalUp)
.LineStyle = XlLineStyle.xlContinuous
.Weight = xlMedium
.Color = RGB(255, 0, 0)
End With
With Selection.Borders(xlDiagonalDown)
.LineStyle = XlLineStyle.xlContinuous
.Weight = xlMedium
.Color = RGB(255, 0, 0)
End With
End Sub
Any ideas would be most appreciated!!!