Fill both cells if one cell has a negative amount

G

GWC

If the cell in COL J contains a negative value, how do I add a yellow fill to both cells on that row?

Here's a portion of my spreadsheet:

COL J COL L
-1398.88 3569.94
7022.00 75.95

-5051.24 5165.80
834.82 282.40
17991.89 809.63

-114.02 138.73
-1.16 19.81
45.72 0.00
35.22 19.81
45.65 19.81
335.61 396.39
712.66 19.34
576.78 69.21

-127.36 607.36
1715.71 125.66

(For example, in row 1, cells J1 and L1 would have yellow fill).
 
G

GS

GWC formulated on Sunday :
If the cell in COL J contains a negative value, how do I add a yellow fill to
both cells on that row?

Here's a portion of my spreadsheet:

COL J COL L
-1398.88 3569.94
7022.00 75.95

-5051.24 5165.80
834.82 282.40
17991.89 809.63

-114.02 138.73
-1.16 19.81
45.72 0.00
35.22 19.81
45.65 19.81
335.61 396.39
712.66 19.34
576.78 69.21

-127.36 607.36
1715.71 125.66

(For example, in row 1, cells J1 and L1 would have yellow fill).

Also already asked and answered!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
S

Sheriff

This should do it (had to add for next loop to handle multiple selection)
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myRng As Range
For Each myRng In Target
If myRng.Column = 10 Then
If myRng.Value < 0 Then
With Union(myRng, myRng.Offset(0, 2)).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
End With
Else
With Union(myRng, myRng.Offset(0, 2)).Interior
.Pattern = xlNone
End With
End If
End If
Next
End Sub

hth
Sheriff
GWC said:
If the cell in COL J contains a negative value, how do I add a yellow fill
to both cells on that row?

Here's a portion of my spreadsheet:

COL J COL L
-1398.88 3569.94
7022.00 75.95

-5051.24 5165.80
834.82 282.40
17991.89 809.63

-114.02 138.73
-1.16 19.81
45.72 0.00
35.22 19.81
45.65 19.81
335.61 396.39
712.66 19.34
576.78 69.21

-127.36 607.36
1715.71 125.66

(For example, in row 1, cells J1 and L1 would have yellow fill).


--- news://freenews.netfront.net/ - complaints: (e-mail address removed) ---
 
B

Ben McClave

Hello,

An easier solution is to use a formula with conditional formatting. To highlight both cells of the same row where a value in column J is negative, select columns J and L (or any other columns you wish) and use this conditional formatting formula:

=$J1<0
 
S

Sheriff

Thanks Ben,
much neater

brgrds

Ben McClave said:
Hello,

An easier solution is to use a formula with conditional formatting. To
highlight both cells of the same row where a value in column J is
negative, select columns J and L (or any other columns you wish) and use
this conditional formatting formula:

=$J1<0


--- news://freenews.netfront.net/ - complaints: (e-mail address removed) ---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top