Results 1 to 4 of 4

Combining Multiple Subs Within Worksheet_Change

Threaded View

  1. #1
    Registered User
    Join Date
    05-29-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    10

    Combining Multiple Subs Within Worksheet_Change

    Hello,

    I understand that it's not possible to have multiple subs within a worksheet_change.
    I've been pulling my hair out trying to combine these subs .

    The sub changes the colour of an autoshape based on the difference between the target cells (thanks to user MickG). I'm trying to multiply this for several shapes with different corresponding cells.

    Perhaps it's not possible? Any help you could offer would be most appreciated!

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Tar As Range
    Set Tar = Range("U121") 'Formula result cell
    If Not Intersect(Target, Range("T101:T121")) Is Nothing Then
        If IsNumeric(Tar.Value) Then
            If Tar.Value > 0.4 Then
                ActiveSheet.Shapes("FreeForm 11").Fill.ForeColor.RGB = vbRed
            ElseIf Tar.Value <= 0.4 And Tar.Value > 0.05 Then
                ActiveSheet.Shapes("FreeForm 11").Fill.ForeColor.RGB = vbYellow
            ElseIf Tar.Value <= 0.05 Then
                ActiveSheet.Shapes("FreeForm 11").Fill.ForeColor.RGB = vbGreen
            End If
        End If
    End If
    End Sub
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Tar As Range
    Set Tar = Range("U117") 'Formula result cell
    If Not Intersect(Target, Range("T101:T117")) Is Nothing Then
        If IsNumeric(Tar.Value) Then
            If Tar.Value > 0.4 Then
                ActiveSheet.Shapes("FreeForm 9").Fill.ForeColor.RGB = vbRed
            ElseIf Tar.Value <= 0.4 And Tar.Value > 0.05 Then
                ActiveSheet.Shapes("FreeForm 9").Fill.ForeColor.RGB = vbYellow
            ElseIf Tar.Value <= 0.05 Then
                ActiveSheet.Shapes("FreeForm 9").Fill.ForeColor.RGB = vbGreen
            End If
        End If
    End If
    End Sub
    
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Tar As Range
    Set Tar = Range("U123") 'Formula result cell
    If Not Intersect(Target, Range("T101:T123")) Is Nothing Then
        If IsNumeric(Tar.Value) Then
            If Tar.Value > 0.4 Then
                ActiveSheet.Shapes("Group 15").Fill.ForeColor.RGB = vbRed
            ElseIf Tar.Value <= 0.4 And Tar.Value > 0.05 Then
                ActiveSheet.Shapes("Group 15").Fill.ForeColor.RGB = vbYellow
            ElseIf Tar.Value <= 0.05 Then
                ActiveSheet.Shapes("Group 15").Fill.ForeColor.RGB = vbGreen
            End If
        End If
    End If
    End Sub
    Last edited by Sean Ross; 06-12-2013 at 06:19 AM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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