title: excel/VBA pass a sheetname to a function
body: <p>i have few sheet, and a need for once of it that a specific cell (A1) is equal "1" the label color become green once the change their value.</p>
  
  <p>I declare in a ThisWorkBook the following function: </p>
  
  <pre><code>Public Function ColorLabel(LabelName)
  Set Foglio = Sheets(LabelName)
  Set Target = Foglio.Range("A1")
  
  If Target = "1" Then
      Foglio.Tab.ColorIndex = 4
  Else
      Foglio.Tab.ColorIndex = xlNone
  end if
  End Function
  </code></pre>
  
  <p>So, in every sheet i define the following code</p>
  
  <pre><code>Private function Worksheet_Change(ByVal Target As Range)
   ColorLabel(ActiveSheet.CodeName)
  end function
  </code></pre>
  
  <p>but I get the following error</p>
  
  <blockquote>
    <p>Compilation error. Expected variable or routine and not form</p>
  </blockquote>
  
  <p>What's wrong?</p>
  
  <p>Someone help me?</p>
  
  <p>Thanks!</p>