Results 1 to 15 of 15

Force Change Event in workbook

Threaded View

  1. #1
    Registered User
    Join Date
    10-10-2008
    Location
    UK
    Posts
    15

    Force Change Event in workbook

    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
    Last edited by romperstomper; 03-22-2011 at 07:56 AM. Reason: code tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1