Highlight row a random color

A

Altan

Visual Basic 6.3/Excel 2003/XP

(Function Question 1)

Column A- has many different ticket numbers sometimes duplicated. Can I
create code to have all duplicated ticket numbers highlighted a random color?
Then hightlight the entire row whatever color that is?

For ex: I would like 1456 on both rows to be any random color that will
continue from Column A to Column F.

Column A Column B ... Column F
1456 NMS Work in Progress
1489 BO Scheduled
1456 Staffed New
1789 NMS Scheduled


(Function Question 2)

Column D has date and time. What code will color the entire row that
matches date and time?

For ex: 5/1/2008 9:00 make this entire row from 1456 (Column A) xColor &
1789 (Column A) That same color.

Column A... Column D ... Column F
1456 5/1/2008 9:00 Work in Progress
1489 5/8/2008 19:00 Scheduled
1456 5/30/2008 3:00 New
1789 5/1/2008 9:00 Scheduled

Thank you for your time....

-Altan
 
G

Gary''s Student

Try this small macro:

Sub altan()
n = Cells(Rows.Count, "A").End(xlUp).Row
v1 = 1
v2 = 56
Set r = Range("A:A")
For i = 1 To n
Set r2 = Cells(i, 1)
m = Application.WorksheetFunction.CountIf(r, r2)
If m > 1 Then
p = Int(((v2 - v1 + 1) * Rnd) + v1)
Cells(i, 1).EntireRow.Interior.ColorIndex = p
End If
Next
End Sub
 

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

Top