title: Excel VBA User Defined Function | Does not work on specific worksheet
body: <p>After several days working on my first User Defined Function (&quot;UDF&quot;), I finally got one working as expected. My function has the purpose of simplifying an &quot;Index+Match+Offset&quot; excel function.</p>
  <p>For example, that is its code :</p>
  <pre><code>Public Function DADOSMACRO(Data_I_want As String, Date_I_want As Date) As Double
  Application.Volatile
  
  Dim year As Integer
  Dim row As Integer
  Dim column As Integer
  
  Year = Year(Data_Procurada)
  Row = Application.WorksheetFunction.Match(Data_I_want, Range(&quot;Macro&quot;).Columns(2), 0)
  Column = Application.WorksheetFunction.Match(Year, Range(&quot;Macro!6:6&quot;).Rows(1), 0)
  
  
  DADOSMACRO = Application.WorksheetFunction.Index(Range(&quot;Macro&quot;), row, column)
  
  
  End Function
  </code></pre>
  <p>The question is, my function works perfectly on several worksheets on my worktable, but I don´t know why, there is a worksheet that every time it´s recalculated, it &quot;broke&quot; my UDF.</p>
  <p>So, if I go to any other worksheet and press F9, my numbers are there, if I go to that specific table and press F9, my whole workbook is &quot;broke&quot;</p>