title: VBA identical nrs not matching in if statement
body: <p>I apologise, I realise this may have been asked a gazillion times already but I've tried looking and I can't find a situation like mine. I'm still learning, and I've never posted here before either so please be gentle with me.</p>
  <p>I am working in Excel VBA. I have two cells (PICKAmt and INVAamt, same sheet) and they each have the exact same number in them, e.g. 399.80.</p>
  <ol>
  <li><p>Even after formatting the cell to 0.00 VBA still reads them both as &quot;399.8&quot;, but also still says they are not the same</p>
  </li>
  <li><p>They are both &quot;Doubles&quot;</p>
  </li>
  <li><p>This same calculation worked under the exact same circumstances on a different sheet</p>
  </li>
  <li><p>My code says:</p>
  <pre><code>Private Function INVACalc(ByVal INVAamt As Double, Holdcell As String, lastcell1 As String) As Double   
  Dim PICKAmt As Double  
  Dim APSDamt As Double  
  Dim lastcell3 As String  
  Dim SUND As String  
  Dim APIE As String
  
  Worksheets(&quot;GL&quot;).Activate  
  Range(lastcell1).Offset(0, 9).NumberFormat = &quot;0.00&quot;  
  Range(lastcell1).Offset(0, 9).Value = Application.WorksheetFunction.Sum(Range(&quot;AL:AL&quot;))         'add up total of all lines  
  PICKAmt = Range(lastcell1).Offset(0, 9).Value  
  If PICKAmt = INVAamt Then    
     'do stuff  
  Else  
    'do something else  
  End if
  </code></pre>
  </li>
  </ol>
  <p>It goes straight to the &quot;Else&quot;, as if the two amounts are not identical, which they are. They have no extra spaces or characters. The only difference I can pick up between them is that the INVAAmt cell is formatted as &quot;Custom&quot; and the PICKAmt cell is formatted as &quot;Number&quot;, but again, this same code does the job just fine on other sheets with the same formatting. I am at a loss.</p>