LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default Search other sheets for numbers & color them

I have two attempts here that are not falling into place for me.
(The sheet names are a bit goofy, but real names in this test workbook.)

Column G on sheet "name1" gets a list of numbers with several repeats.
On all the other sheets (except sheet "dont touch this sheet") there are many number on each sheet.

For each unique number on sheet "name1" if it occurs on any of the other sheets then color the font the same color. (If I can get it to do the font then I can swap to color the cell if I prefer)

So I have some very scant results with the two attempts below.
First I make a unique list in column F the shoot for a For Each loop on that F column and then a For Each loop on the worksheets and increment the colorindex by 1 for each number, which starts at colorindex 3.

I'm getting a couple of colors on one or two other sheets and some of the different numbers on the others sheet are the same color. Its pretty screwy.

In the second code this errors With Sheets(varSheets(i))

I intend to delete the F column list after the code runs successfully.
I have verified that the numbers are really numbers by using an =SUM(....) on the them.

Thanks,
Howard

Sub SearchColor()
Dim ws As Worksheet
Dim lrow As Long
Dim CheckNum As Range
Dim i As Long
Dim frow As Long
Dim c As Range
Dim cc As Long

lrow = Cells(Rows.Count, "G").End(xlUp).Row
Range("G2:G" & lrow).Copy Range("F" & Rows.Count).End(xlUp)(2)
Range("F2:F" & lrow).RemoveDuplicates 1
frow = Cells(Rows.Count, "G").End(xlUp).Row

For Each CheckNum In Range("F2:F" & frow)
cc = 3
For Each ws In ThisWorkbook.Sheets
If (ws.Name < "dont touch this sheet") And (ws.Name < "name1") Then
With ws
Set CheckNum = .UsedRange.Find(What:=CheckNum, LookIn:=xlValues)
If Not CheckNum Is Nothing Then
CheckNum.Font.ColorIndex = cc
' CheckNum.Interior.ColorIndex = cc
End If
End With
End If
Next 'ws
cc = cc + 1
Next 'c
End Sub


Sub ColorNumCells()
Dim ws As Worksheet
Dim lrow As Long
Dim CheckNum As Range
Dim varSheets As Variant
Dim i As Long
Dim frow As Long
Dim cc As Long

lrow = Cells(Rows.Count, "G").End(xlUp).Row
Range("G2:G" & lrow).Copy Range("F" & Rows.Count).End(xlUp)(2)
Range("F2:F" & lrow).RemoveDuplicates 1
frow = Cells(Rows.Count, "G").End(xlUp).Row

varSheets = Array("name", "another name", "etc.", "etc..", "etc....")
cc = 3
For i = LBound(varSheets) To UBound(varSheets)
For Each CheckNum In Range("F2:F" & frow)
With Sheets(varSheets(i)) '/error here

Set CheckNum = .UsedRange.Find(What:=CheckNum, LookIn:=xlValues)

If Not CheckNum Is Nothing Then
'CheckNum.Interior.ColorIndex = cc
CheckNum.Font.ColorIndex = cc
End If

End With
Next 'Each
cc = cc + 1
Next 'i

End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with printing multiple sheets-only 1 sheet prints in color, other sheets print in B&W Luc[_7_] Excel Programming 0 November 29th 10 10:31 PM
Search and then format by color swimeveryday Excel Discussion (Misc queries) 1 April 13th 10 06:00 AM
Making a cell a color using color numbers Roger on Excel Excel Programming 7 September 3rd 08 01:33 PM
can you search by the color of the font? Boggshead Excel Discussion (Misc queries) 2 May 8th 07 12:12 AM
Can i search for cells of a particular color Ashutosh Excel Discussion (Misc queries) 1 November 22nd 06 05:18 PM


All times are GMT +1. The time now is 04:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"