abdelfattah
Well-known Member
- Joined
- May 3, 2019
- Messages
- 1,429
- Office Version
- 2019
- 2010
- Platform
- Windows
hello
i try writing code in earlier time it was working but now it works only to specific row 2,5 my idea when the value "paid" is existed in column a then should highlight the cells in columns I,J,K
as in my picture in row6 should be color because column e contains "paid"
this is my code
i try writing code in earlier time it was working but now it works only to specific row 2,5 my idea when the value "paid" is existed in column a then should highlight the cells in columns I,J,K
as in my picture in row6 should be color because column e contains "paid"
this is my code
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("e:e")) Is Nothing Then
Dim i As Long, r1 As Range, r2 As Range
lr = Cells(Rows.Count, 1).End(xlUp).Row + 1
For i = 2 To lr
Set r1 = Range("e" & i)
Set r2 = Range("i" & i & ":k" & i)
If r1.Value = "paid" Then
r2.Interior.color = vbBlue
Else
r2.Interior.ColorIndex = xlNone
End If
Next i
End If
End Sub
color (1).xlsm | |||||||||
---|---|---|---|---|---|---|---|---|---|
E | F | G | H | I | J | K | |||
1 | case | debit | credit | balance | |||||
2 | paid | 1000 | 200 | 800 | |||||
3 | unpaid | 1000 | 1000 | ||||||
4 | paid | 2000 | 500 | 1500 | |||||
5 | unpaid | 1020 | 1020 | ||||||
6 | paid | 1200 | 200 | 1000 | |||||
13 |
Cells with Conditional Formatting | ||||
---|---|---|---|---|
Cell | Condition | Cell Format | Stop If True | |
E4 | Cell Value | =1 | text | NO |
C1:E1 | Cell Value | =1 | text | NO |
C2:C3,E6,E2:E3 | Cell Value | =1 | text | NO |