A worksheet function applied to all

BMD

Board Regular
Joined
Oct 5, 2005
Messages
211
This is my working function,,,,,, but it only works for Sheet1 and I tryed to copy it to ThisWorkbook but it does not work for any other sheet. Do I realy need to copy it to all sheet and mainten all of them?

Thanks,
This group is excellence,
The Learning, Bruce.

'"Pass" in cell G row A:O Green.
'"Fail" in cell G row A:O Red
'"Pass" in cell G cell M is = "to {Major or Minor}" turn the row A:O Yellow.
Option Compare Text
Public Sub demo()
Letter = "P"
If Letter = "p" Then MsgBox "Case does not matter"
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim WatchRange As Range
Dim cell As Range
Dim rng As Range

Set WatchRange = Columns("G")
Set WatchRangeM = Columns("M")
Dim myMultiAreaRange As Range
Set myMultiAreaRange = Union(WatchRange, WatchRangeM)

If Intersect(Target, myMultiAreaRange) Is Nothing Then Exit Sub
Set rng = Intersect(Target, myMultiAreaRange)

For Each cell In rng
With Range(Cells(cell.Row, "A"), Cells(cell.Row, "O")).Font
Select Case LCase(cell):
Case "Pass", "P"
If Cells(cell.Row, "M") = "Major" Or Cells(cell.Row, "M") = "Minor" Or Cells(cell.Row, "M") = "Maj" Or Cells(cell.Row, "M") = "Min" Then
.ColorIndex = 33
.Bold = True
Else
.ColorIndex = 10
.Bold = False
End If
Case "Major", "Maj", "Minor", "Min"
If Cells(cell.Row, "G") = "Pass" Or Cells(cell.Row, "G") = "P" Then
.ColorIndex = 33
.Bold = True
Else
.ColorIndex = 10
.Bold = False
End If
Case "Fail", "F"
.ColorIndex = 3
.Bold = False
Case Else
.ColorIndex = 1
.Bold = False
End Select:
End With
Next cell
End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
I just copied it to thisWorkbook and removed all other refferences and I think it is working now......
Let me run some tests on it.
 
Upvote 0
Where did you put the code? It should be in the ThisWorkbook module.

Is the code actually being run?

Try this, create a breakpoint in the code by pressing F9.

When you change a value on a sheet does the VBE open at the code?
 
Upvote 0
It was in Modules and called Module1. It is now in ThisWorkbook and running. I will add to it and add checking for a Fail with a Major and display a user message.

THANK YOU,
The Learning. Bruce.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,557
Members
449,088
Latest member
davidcom

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