You need to change Range("D38:D39") in the code to the cell or cells that you enter manually and that determine the outcome of the formula in D2.
Alternatively, use this code, but it has a higher overhead:
Private Sub Worksheet_Calculate()
On Error GoTo ErrHandler
Me.ChartObjects(1).Chart.Axes(xlCategory).MaximumScale = Range("D2").Value
Exit Sub
ErrHandler:
MsgBox Err.Description, vbExclamation
End Sub