Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing Cell Color based upon value on another worksheet
I need help cell coloring based upon matching data on 2 sheets.
'Sheet1' - Data Dump 'Sheet2' - New Formatting 'Sheet1' column AD = "No" then find value on same row but in Column B Then search on 'Sheet2' for that value in Column B. If found, color the field in the row above it Red (Color.Index = 3) I need to check each row of column AD on 'Sheet1' for value = "No" and search all fields on 'Sheet2' for the value in Column B of same row. The colored cell on 'Sheet2' will always in the the same column but 1 row up. Thank you for any assistance you can provide. Dwayne P. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing Cell Color based upon value on another worksheet
If I understood the parameters correctly, this should work. You can rename
the sheets to suit in the Set statements. Sub colorNo() Dim sh1 As Worksheet, sh2 As Worksheet, fStr As Variant Dim lr1 As Long, rng As Range, fRng As Range Set sh1 = Sheets("Sheet1") Set sh2 = Sheets("Sheet2") lr1 = sh1.Cells(Rows.Count, "AD").End(xlUp).Row Set rng = sh1.Range("AD2:AD" & lr1) For Each c In rng If c.Value = "No" Then fStr = sh1.Range("B" & c.Row).Value With sh2 Set fRng = .UsedRange.Find(fStr, LookIn:=xlValues, LookAt:=xlWhole) If Not fRng Is Nothing Then fAddr = fRng.Address Do fRng.Offset(-1).Interior.ColorIndex = 3 Set fRng = .UsedRange.FindNext(fRng) Loop While Not fRng Is Nothing And fRng.Address < fAddr End If End With End If Next End Sub "DPelletier" wrote in message ... I need help cell coloring based upon matching data on 2 sheets. 'Sheet1' - Data Dump 'Sheet2' - New Formatting 'Sheet1' column AD = "No" then find value on same row but in Column B Then search on 'Sheet2' for that value in Column B. If found, color the field in the row above it Red (Color.Index = 3) I need to check each row of column AD on 'Sheet1' for value = "No" and search all fields on 'Sheet2' for the value in Column B of same row. The colored cell on 'Sheet2' will always in the the same column but 1 row up. Thank you for any assistance you can provide. Dwayne P. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing Cell Color based upon value on another worksheet
On Nov 5, 5:16*pm, "JLGWhiz" wrote:
If I understood the parameters correctly, this should work. *You can rename the sheets to suit in the Set statements. Sub colorNo() * *Dim sh1 As Worksheet, sh2 As Worksheet, fStr As Variant * *Dim lr1 As Long, rng As Range, fRng As Range * *Set sh1 = Sheets("Sheet1") * *Set sh2 = Sheets("Sheet2") * *lr1 = sh1.Cells(Rows.Count, "AD").End(xlUp).Row * *Set rng = sh1.Range("AD2:AD" & lr1) * * * For Each c In rng * * * * *If c.Value = "No" Then * * * * * *fStr = sh1.Range("B" & c.Row).Value * * * * * *With sh2 * * * * * *Set fRng = .UsedRange.Find(fStr, LookIn:=xlValues, LookAt:=xlWhole) * * * * * * * If Not fRng Is Nothing Then * * * * * * * * *fAddr = fRng.Address * * * * * * * * * * Do * * * * * * * * * * * * fRng.Offset(-1).Interior.ColorIndex = 3 * * * * * * * * * * * * Set fRng = .UsedRange.FindNext(fRng) * * * * * * * * * * Loop While Not fRng Is Nothing And fRng.Address < fAddr * * * * * * * *End If * * * * * * * *End With * * * * * End If * * * *Next End Sub "DPelletier" wrote in message ... I need help cell coloring based upon matching data on 2 sheets. 'Sheet1' - Data Dump 'Sheet2' - New Formatting 'Sheet1' column AD = "No" then find value on same row but in Column B Then search on 'Sheet2' for that value in Column B. *If found, color the field in the row above it Red (Color.Index = 3) I need to check each row of column AD on 'Sheet1' for value = "No" and search all fields on 'Sheet2' *for the value in Column B of same row. The colored cell on 'Sheet2' will always in the the same column but 1 row up. Thank you for any assistance you can provide. Dwayne P. Works like a charm. Thank you for your time. I could not get the find value to work before. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Changing the color of a cell in excel based on due date | Excel Worksheet Functions | |||
Changing Cell Color Based on Value | Excel Worksheet Functions | |||
Changing font color based on type cell it is. How to do it? | Excel Programming | |||
Changing background color based on different cell | Excel Discussion (Misc queries) | |||
Changing cell color based on its value | Excel Programming |