REPSOT?? Sub Worksheet_Change(ByVal Target As Range)
Put the code in ThisworkBook.
Added sheets to skip.
Changed colorindex to 3 as the cells are already 4.
Nothing happens at all.
Tried to step through but will not go just got beep.
Put Application.EnableEvents=True in immediate window
Still nothing happens.
--
Thank You in Advance
Ed Davis
"Dave Peterson" wrote in message
...
If there are lots of sheets that need this requirement, there are probably
a few
that don't (instructions or ????).
This is a workbook level event and goes in the ThisWorkbook module:
Option Explicit
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
Dim myCell As Range
Dim myIntersect As Range
Dim myAddresses As String
Dim SheetNamessToSkip As Variant
Dim res As Variant
SheetNamessToSkip = Array("Instructions", "Othersheetname")
myAddresses = "G12:H51,P40:Q44,P48:Q60,Q14:Q17"
res = Application.Match(Sh.Name, SheetNamessToSkip, 0)
If IsNumeric(res) Then
'it's in that array of names to skip
'do nothing
Else
Set myIntersect = Intersect(Sh.Range(myAddresses), Target)
If myIntersect Is Nothing Then
'do nothing
Else
For Each myCell In myIntersect.Cells
If myCell.HasFormula Then
'skip it, change the color back???
Else
myCell.Interior.ColorIndex = 4
End If
Next myCell
End If
End If
End Sub
I wasn't sure what should happen if someone puts the formula back--you may
want
to remove that check or change the color????
Ed Davis wrote:
I have 4 rages of cells that if any cell in these ranges changes I would
like to change the Background and Foreground colors.
However I only want to change that cells color not all of them.
Rather than use "Sub Worksheet_Change(ByVal Target As Range)" I would
like
to use a macro because I have 32 sheets with these same ranges.
Currently when the user changes any of these cells a macro runs that
saves
the active sheet as a workbook and changes the tab color to red to
indicate
a change has (possibly) been made.
I currently have no way of knowing what cell has been changed or for that
matter if any changes have been made at all.
The cell ranges are G12:H51, P40:Q44, P48:Q60 and Q14:Q17.
These cells have formulas in them and I allow the user to over ride with
a
number if it is incorrect.
I tried CF and have had no success.
A function was created to check if the cells had a formula. When using
the
formula in CF it made a lot of other macros BOMB. Don't know the reason
but
when that CF was removed all macros ran properly again.
I have seen a lot of information on using "Sub Worksheet_Change(ByVal
Target
As Range)" but they all refer to 1 range and coloring the whole range.
Any help with this would be greatly appreciated.
--
Thank You in Advance
Ed Davis
--
Dave Peterson
|