Please help. I am trying to calculate a formula then let the textbox show the number. The textbox's controlsource is d23. The formula should be in cell d23. I want to subtract d22-d21, which is control sources of two other textboxes. Can someone have a look at my two codes below, and tell me what I am doing wrong, if you need the excel file let me know.
Private Sub txtironmass_Change()
Dim myrange1 As range
Set myrange1 = Worksheets("program").range("d23")
If Cells("d22") > 0 Then
myrange1("D23").Select
ActiveCell.FormulaR1C1 = "=R[-1]C-R[-2]C"
Else: range("d23").Select = 0
End If
End Sub
Private Sub txtironmass_Change()
Dim x As range
Set x = Worksheets("program").range("d23")
x.Select
ActiveCell.Formula = "=z-y"
End Sub
Private Sub txtironmass_Change()
Dim myrange1 As range
Set myrange1 = Worksheets("program").range("d23")
If Cells("d22") > 0 Then
myrange1("D23").Select
ActiveCell.FormulaR1C1 = "=R[-1]C-R[-2]C"
Else: range("d23").Select = 0
End If
End Sub
Private Sub txtironmass_Change()
Dim x As range
Set x = Worksheets("program").range("d23")
x.Select
ActiveCell.Formula = "=z-y"
End Sub