Hi, I am trying to create a function that will take a fixed value, and increment another cell. It does this until another cell using a formula equals the fixed value. You can see what I have below, but this is my first VBA programming ever so I dont know exactly how to declare everything.

Function meetMargin(Margin, calcM, nrc)
  Dim x0 As Double, x1 As Double, x2 As Double, t1 As Double
  t1 = 0.05
  Do While t1 >= 0.01
  x0 = Range("Margin").Value
  x1 = Range("calcM").Value
  Range("nrc").Value = Range("nrc").Value + 0.01
  
  x2 = Range("nrc").Value
  t1 = x0 - x1
  
  Loop
  meetMargin = x2

End Function