Please can anyone help with the following;
I Have a workbook with various named worksheets which I use to calculate perfomance based on Total No. of items handled divided by total labour hours used giving me a value for Items per Labour Hour. Depending on this value some cells are formatted in a colour in order to draw the users attention to it. I also have a summary sheet where some of the info from each worksheet is displayed. On the summary sheet there is a target value for items per labour hour. The individual worksheets code works fine but I cannot get the worksheet cells to reformat if I ammend the target value on the summary.
I have used the following code on the ThisWorkbook Change event
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim ws As Worksheet
Select Case Sh.Name
Case "ICE X 10", "CHINA", "COS", "ICEX12", "HEARTS", "gem", "CELERY", "STICKS" 'Excluded Summary sheet
FormatSheet Sh
Case "Summary"
For Each ws In ThisWorkbook.Worksheets
Select Case ws.Name
Case "ICE X 10", "CHINA", "COS", "ICEX12", "HEARTS", "gem", "CELERY", "STICKS" 'Excluded Summary sheet
FormatSheet ws
End Select
Next
End Select
End Sub
and also
Created a module with the following code
Sub FormatSheet(ws As Worksheet)
Dim i As Integer, nColor
With ws
If ws.Name <> "STICKS" Then
i = 0
Else
i = 3
End If
If .Cells(22, 3).Value & .Cells(22, 4).Value & .Cells(22, 5).Value <> "" Then
If .Cells(30, 16).Value < Worksheets("Summary").Cells(6, 10).Value Then
nColor = RGB(255, 0, 0)
Else
nColor = RGB(0, 255, 0)
End If
Else
nColor = RGB(255, 255, 153)
End If
.Range(.Cells(33 + i, "J"), .Cells(39 + i, "Q")).Interior.Color = nColor
.Cells(30 + i, "P").Interior.Color = nColor
End With
End Sub
Cheers
Colin
Bookmarks