Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Worksheet Functions / May 2008

Tip: Looking for answers? Try searching our database.

Highlight row a random color

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Altan - 21 May 2008 12:08 GMT
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
Gary''s Student - 21 May 2008 13:35 GMT
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
Signature

Gary''s Student - gsnu200787

> Visual Basic 6.3/Excel 2003/XP
>
[quoted text clipped - 31 lines]
>
> -Altan
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.