Thread: easy macro?
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
GB GB is offline
external usenet poster
 
Posts: 230
Default easy macro?

This will cause a value to be marked twice when in fact it can only be offset
one time. (i.e., if -1000 is in the list twice, but 1000 is only present
once, then 1000 will be marked twice (Though you wouldn't really know it.))
An additional test should be added that if the cell interior color is already
= k then do not use that cell for comparison. Yeah it's a dirty solution but
works. Depends on how nicely you want this thing to work/look. To prevent
this, you might also be able to set n = c.row + 1 instead of n = 1. Afterall
if you started at the beginning of the list, and have already found a match
with the first item, why look at the first item again later? I think though,
you will still need to verify that cells(n,1) interior color is not already =
k before testing that they cancel each other out.

My two cents...


"davidm" wrote:


This may not be pretty, but it may do what you want ie pair off the
matches

Sub nn()
For Each c In [a:a]
If Not IsEmpty(c) Then
x = c.Value
n = 1
k = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Do Until Cells(n, 1) = ""
If x + Cells(n, 1) = 0 Then
c.Interior.Color = k
Cells(n, 1).Interior.Color = k
End If
n = n + 1
Loop
End If
Next
End Sub


David


--
davidm
------------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=501981