I am creating a program which will find a function maximum to give a profit. This profit function is equiped with an error function to prevent ordering more stock than can be obtained.

The function itself is in excel and is only used as a value in VB.
Code:
   
    xa = 90
    xb = 90
    Cells(6, 5).Value = xa
    Cells(7, 5).Value = xb
    
    Profit = Cells(4, 9).Value
...