Forum Discussion
Bziku_maly
Apr 28, 2022Copper Contributor
Changing a cell value based on cell background colour
Hi for now I have created a separate formula CellColour for each cell =GET.CELL(63,'22.04.27'!P3) to =GET.CELL(63,'22.04.27'!P17) and set of nested if how to change a colour for corresponding ...
- Apr 28, 2022
Sub color() Dim i As Integer For i = 3 To 50 Select Case Cells(i, 3).Interior.ColorIndex Case Is = 44 Cells(i, 2).Value = 0.9 * Cells(i, 16).Value Case Is = 43 Cells(i, 2).Value = 1 * Cells(i, 16).Value Case Is = 33 Cells(i, 2).Value = 1.1 * Cells(i, 16).Value Case Is = 2 Cells(i, 2).Value = 1 * Cells(i, 16).Value Case Is = 3 Cells(i, 2).Value = 0.8 * Cells(i, 16).Value End Select Next i End SubMaybe with these lines of code. Click the button in cell E2 in the attached file to start the macro.
OliverScheurich
Apr 28, 2022Gold Contributor
Sub color()
Dim i As Integer
For i = 3 To 50
Select Case Cells(i, 3).Interior.ColorIndex
Case Is = 44
Cells(i, 2).Value = 0.9 * Cells(i, 16).Value
Case Is = 43
Cells(i, 2).Value = 1 * Cells(i, 16).Value
Case Is = 33
Cells(i, 2).Value = 1.1 * Cells(i, 16).Value
Case Is = 2
Cells(i, 2).Value = 1 * Cells(i, 16).Value
Case Is = 3
Cells(i, 2).Value = 0.8 * Cells(i, 16).Value
End Select
Next i
End Sub
Maybe with these lines of code. Click the button in cell E2 in the attached file to start the macro.
- Bziku_malyApr 28, 2022Copper ContributorThank you