title: Function execution with parameters in VBA
body: <p>I'm creating a function
  that has as a parameter a day of the week (Monday, Wednesday, Thursday ...) that captures the day of the respective month of the week and returns its day in the cell, on Sundays the day value is reset</p>
  <pre><code>Function dayReference(week as Integer)
  
      If Weekday(Date, 1) = week Then
          ActiveCell.FormulaR1C1 = Day(Date)
      ElseIf Weekday(Date, 1) = 1 Then
          ActiveCell.FormulaR1C1 = &quot;&quot;
      End If        
  
  End Function
  </code></pre>
  <p>I'm having 2 problems:</p>
  <ol>
  <li>With a parameter I cannot call the function either manually or through the spreadsheet, without the parameter I can call it manually.</li>
  </ol>
  <p>Example: in the cell of my spreadsheet if I type dayReference (7) excel asks to create a macro or select an existing one, as my model is a function and not a macro I can't call it</p>
  <ol start="2">
  <li>My goal is not to have to execute this script manually by the editor, but to have the behavior of native functions like Day and Date, which are dynamic, and I can make the call in any cell</li>
  </ol>
  <p>What is the most efficient way to create it using ?</p>