Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
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
Changing the color of a cell in excel based on due date MPatterson Excel Worksheet Functions 2 March 19th 12 03:34 AM
Changing Cell Color Based on Value DisMusBeDaPlaz Excel Worksheet Functions 2 December 31st 09 04:55 AM
Changing font color based on type cell it is. How to do it? Chet Excel Programming 6 November 24th 08 02:30 AM
Changing background color based on different cell djarcadian Excel Discussion (Misc queries) 3 August 10th 06 10:44 PM
Changing cell color based on its value spolk[_8_] Excel Programming 9 June 1st 04 08:24 AM


All times are GMT +1. The time now is 09:43 PM.

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

About Us

"It's about Microsoft Excel"