Program works when programmed, but when re opening Excel I get a Compile Error: Expec

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Travis C
    New Member
    • May 2012
    • 1

    Program works when programmed, but when re opening Excel I get a Compile Error: Expec

    Formula as follows... i am not sure what is causing the error... sorry for breaking rule 3.

    Sub COLOR()
    Sub Worksheet_Chang e(ByVal Target As Excel.Range)
    If Intersect(Targe t, Range("AH6:AH55 000")) Is Nothing Then
    Exit Sub
    Else
    DidCellsChange
    End If
    End Sub

    Sub DidCellsChange( )
    Dim KeyCells As String
    ' Define which cells should trigger the KeyCellsChanged macro.
    KeyCells = "AH6:AH5500 0"

    ' If the Activecell is one of the key cells, call the
    ' KeyCellsChanged macro.
    If Not Application.Int ersect(ActiveCe ll, Range(KeyCells) ) _
    Is Nothing Then KeyCellsChanged

    End Sub

    Sub KeyCellsChanged ()
    Dim Cell As Object

    For Each Cell In Range("AH6:AH55 000")

    If Cell = "AH" Then

    ' Make the background color of the cell the 3rd color on the
    ' current palette.
    ElseIf Cell = "DISCARD" Then
    Cell.EntireRow. Interior.ColorI ndex = 3
    ElseIf Cell = "" Then
    ' Otherwise, set the background to none (default).
    Cell.EntireRow. Interior.ColorI ndex = xlNone

    End If

    Next Cell

    End Sub
  • firexfighterx
    New Member
    • May 2012
    • 14

    #2
    You arnt running the program when the excel file is open are you? If you are then the reader of the excel file will fail because someone else (you) have the file opened somewhere else.

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      What are the details of the error? All that made it into the title is "Expec".

      Comment

      Working...