Conditional Formatting Across Worksheets

Chris11

New Member
Joined
Sep 20, 2011
Messages
19
Hi All,

New to this forum but im hoping you can help, as I'm struggling to get this task done at work.

I've got a conditional formatting macro for my worksheet as I have more than 3 conditions.
But now I need to use information from another worksheet (in the same workbook) in the macro.
Basically I dont know how to reference the new worksheet.

This is what I Currently have:



Private Sub Worksheet_Change(ByVal Target As Range)
Set MyPlage = Range("D5:D69")
For Each Cell In MyPlage

If Cell.Value = "8601" Then
Cell.Interior.ColorIndex = 41
End If

If Cell.Value = "8501" Then
Cell.Interior.ColorIndex = 43
End If

If Cell.Value = "4901" Then
Cell.Interior.ColorIndex = 46
End If

If Cell.Value = "4902" Then
Cell.Interior.ColorIndex = 44
End If

If Cell.Value = "3802" Then
Cell.Interior.ColorIndex = 47
End If

If Cell.Value = "3802(D)" Then
Cell.Interior.ColorIndex = 7
End If

If Cell.Value = "8504" Then
Cell.Interior.ColorIndex = 18
End If

If Cell.Value = "Not listed" Then
Cell.Interior.ColorIndex = 15
End If


Next
End Sub




Thanks in advance!

Chris A
 
It goes in the code module for Sheet1. Then if you change a value anywhere in the range D6:N71, it will find the cell on sheet2 that contains that value and apply that cell's fill colour to the cell on Sheet1 (if the value is not found, it clears the colour)
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
It goes in the code module for Sheet1. Then if you change a value anywhere in the range D6:N71, it will find the cell on sheet2 that contains that value and apply that cell's fill colour to the cell on Sheet1 (if the value is not found, it clears the colour)

Hmm Saying there is an error on this line:

Code:
Set rngData = Sheets("Sheet3").Range("A2:A40")
 
Upvote 0
Then I guess you don't have a sheet called Sheet3.
 
Upvote 0
What's the error? Subscript out of range?
 
Upvote 0
Then you do not have a sheet called Sheet3. :)
 
Upvote 0
Then you do not have a sheet called Sheet3. :)

DERP.

You are correct, I thought because it was called Sheet3 (Build Variables) I could just call it sheet3.

Cheers man, you're a friggin genius...

(All works now)

Thanks,

Chris A
 
Upvote 0
Since you know what a codename is, I'd actually suggest you use it in preference to the name:
Code:
Set rngData = Sheet3.Range("A2:A40")
 
Upvote 0
Since you know what a codename is, I'd actually suggest you use it in preference to the name:
Code:
Set rngData = Sheet3.Range("A2:A40")


haha, Yeah cool, 'cos then if someone changes the Sheet name its not gonna screw everything up.

Thanks Again.

Chris
 
Upvote 0

Forum statistics

Threads
1,225,156
Messages
6,183,246
Members
453,152
Latest member
ChrisMd

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top