Two text boxes write in each the problem

myfe

Board Regular
Joined
Jul 1, 2012
Messages
58
Hi, </SPAN>
I have this code:</SPAN>

Private Sub TextBox135_Change()
On Error Resume Next
TextBox138.Value = Format(CDbl(TextBox135.Value) / CDbl(TextBox86.Value), "0.0000")
TextBox136.Value = Format(CDbl(TextBox90.Value) + CDbl(TextBox138.Value), "0.0000")
TextBox137.Value = Format(CDbl(TextBox136.Value) / CDbl(TextBox21.Value), "0.0000")
TextBox134.Value = Format(CDbl(TextBox137.Value) - CDbl(TextBox85.Value), "0.0000")

End Sub
Private Sub TextBox136_Change()
On Error Resume Next
TextBox137.Value = Format(CDbl(TextBox136.Value) / CDbl(TextBox21.Value), "0.0000")
TextBox134.Value = Format(CDbl(TextBox137.Value) - CDbl(TextBox85.Value), "0.0000")
TextBox138.Value = Format(CDbl(TextBox136.Value) - CDbl(TextBox90.Value), "0.0000")
TextBox135.Value = Format((CDbl(TextBox137.Value) - CDbl(TextBox90.Value)) * CDbl(TextBox86.Value), "0.0000")



it suppose to take one input and calculate for the other variables the problem is that once it writes the outputs the other text box it activates the second text box code so I keep getting the error ‘13’ and the result is the same no matter what number I put please help me to solve this problem.</SPAN>
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hi Andrew,

I fixed the Typo but the codes are still acting crazy.
The First one works perfectly.
while, the second one works only if I code one text box. On the other hand, if I put a code in another text box with the first one it jams.
I tried everything I could the problem is that there is no error but the code just stops.
I tried taking the code in a fresh new user form and test it by eliminating every factor in the code that might cause this. The only thing that makes it work is when I put a code in one text box only and delete the others.
Now what is really driving me crazy is that I have this code who is almost Identical to it and it works perfectly.
I will put both code the one who work and the one who doesn't and you help me with that please.

I really appreciate all your help and support it is like having my own personal consultant.

The Code that works:

Private Sub TextBox135_Change()
TextBox135.Text = Format(TextBox135.Text, "#,###,###")




If Me.EnableEvents = False Then Exit Sub
Me.EnableEvents = False
On Error Resume Next

TextBox138.Value = Format(CDbl(TextBox135.Value)* CDbl(TextBox86.Value), "0.0000")
TextBox136.Value = Format(CDbl(TextBox90.Value) - CDbl(TextBox138.Value), "0.0000")
TextBox137.Value = Format(CDbl(TextBox136.Value)* CDbl(TextBox21.Value), "0.0000")
TextBox134.Value = Format(CDbl(TextBox137.Value) + CDbl(TextBox85.Value), "0.0000")
Me.EnableEvents = True



End Sub




Private Sub TextBox136_Change()


If Me.EnableEvents = False Then Exit Sub
Me.EnableEvents = False


On Error Resume Next
TextBox137.Value = Format(CDbl(TextBox136.Value) * CDbl(TextBox21.Value), "0.0000")
TextBox134.Value = Format(CDbl(TextBox137.Value) + CDbl(TextBox85.Value), "0.0000")
TextBox138.Value = Format(CDbl(TextBox136.Value) + CDbl(TextBox90.Value), "0.0000")
TextBox135.Value = Format((CDbl(TextBox138.Value) / CDbl(TextBox86.Value)), "0.0000")


Me.EnableEvents = True




End Sub





The code that Doesn't work:

Private Sub TextBox14_Change()
TextBox14.Text = Format(TextBox14.Text, "#,###,###")


If Me.EnableEvents = False Then Exit Sub
Me.EnableEvents = False


On Error Resume Next


TextBox19.Value = Format(CDbl(TextBox14.Value) / CDbl(TextBox9.Value), "0.0000")
TextBox16.Value = Format(CDbl(TextBox13.Value) - CDbl(TextBox19.Value), "0.0000")
TextBox17.Value = Format(CDbl(TextBox16.Value) / CDbl(TextBox20.Value), "0.0000")
TextBox18.Value = Format(CDbl(TextBox149.Value) - CDbl(TextBox17.Value), "0.0000")


Me.EnableEvents = True


End Sub


Private Sub TextBox16_Change()


If Me.EnableEvents = False Then Exit Sub
Me.EnableEvents = False


On Error Resume Next


TextBox17.Value = Format(CDbl(TextBox16.Value) / CDbl(TextBox20.Value), "0.0000")
TextBox18.Value = Format(CDbl(TextBox149.Value) - CDbl(TextBox17.Value), "0.0000")
TextBox19.Value = Format(CDbl(TextBox13.Value) - CDbl(TextBox16.Value), "0.0000")
TextBox14.Value = Format(CDbl(TextBox19.Value) * CDbl(TextBox9.Value), "0.0000")


Me.EnableEvents = True


End Sub
Private Sub TextBox17_Change()
If Me.EnableEvents = False Then Exit Sub
Me.EnableEvents = False


On Error Resume Next


TextBox16.Value = Format(CDbl(TextBox17.Value) * CDbl(TextBox20.Value), "0.0000")
TextBox18.Value = Format(CDbl(TextBox149.Value) - CDbl(TextBox17.Value), "0.0000")
TextBox19.Value = Format(CDbl(TextBox13.Value) - CDbl(TextBox16.Value), "0.0000")
TextBox14.Value = Format(CDbl(TextBox19.Value) * CDbl(TextBox9.Value), "0.0000")


Me.EnableEvents = True


End Sub
Private Sub TextBox18_Change()
If Me.EnableEvents = False Then Exit Sub
Me.EnableEvents = False


On Error Resume Next


TextBox17.Value = Format(CDbl(TextBox149.Value) - CDbl(TextBox18.Value), "0.0000")
TextBox16.Value = Format(CDbl(TextBox17.Value) * CDbl(TextBox20.Value), "0.0000")
TextBox19.Value = Format(CDbl(TextBox13.Value) - CDbl(TextBox16.Value), "0.0000")
TextBox14.Value = Format(CDbl(TextBox19.Value) * CDbl(TextBox9.Value), "0.0000")


Me.EnableEvents = True
End Sub


Private Sub TextBox19_Change()
If Me.EnableEvents = False Then Exit Sub
Me.EnableEvents = False


On Error Resume Next


TextBox16.Value = Format(CDbl(TextBox13.Value) - CDbl(TextBox19.Value), "0.0000")
TextBox17.Value = Format(CDbl(TextBox16.Value) / CDbl(TextBox20.Value), "0.0000")
TextBox18.Value = Format(CDbl(TextBox149.Value) - CDbl(TextBox17.Value), "0.0000")
TextBox14.Value = Format(CDbl(TextBox19.Value) * CDbl(TextBox9.Value), "0.0000")


Me.EnableEvents = True
End Sub

Thanx
 
Upvote 0
This seems to work OK:

Code:
Public EnableEvents As Boolean

Private Sub UserForm_Initialize()
    Me.EnableEvents = True
End Sub

Private Sub TextBox14_Change()
    If Me.EnableEvents = False Then Exit Sub
    Me.EnableEvents = False
    TextBox14.Text = Format(TextBox14.Text, "#,###,###")
    On Error Resume Next
    TextBox19.Value = Format(CDbl(TextBox14.Value) / CDbl(TextBox9.Value), "0.0000")
    TextBox16.Value = Format(CDbl(TextBox13.Value) - CDbl(TextBox19.Value), "0.0000")
    TextBox17.Value = Format(CDbl(TextBox16.Value) / CDbl(TextBox20.Value), "0.0000")
    TextBox18.Value = Format(CDbl(TextBox149.Value) - CDbl(TextBox17.Value), "0.0000")
    Me.EnableEvents = True
End Sub

Private Sub TextBox16_Change()
    If Me.EnableEvents = False Then Exit Sub
    Me.EnableEvents = False
    On Error Resume Next
    TextBox17.Value = Format(CDbl(TextBox16.Value) / CDbl(TextBox20.Value), "0.0000")
    TextBox18.Value = Format(CDbl(TextBox149.Value) - CDbl(TextBox17.Value), "0.0000")
    TextBox19.Value = Format(CDbl(TextBox13.Value) - CDbl(TextBox16.Value), "0.0000")
    TextBox14.Value = Format(CDbl(TextBox19.Value) * CDbl(TextBox9.Value), "0.0000")
    Me.EnableEvents = True
End Sub

Private Sub TextBox17_Change()
    If Me.EnableEvents = False Then Exit Sub
    Me.EnableEvents = False
    On Error Resume Next
    TextBox16.Value = Format(CDbl(TextBox17.Value) * CDbl(TextBox20.Value), "0.0000")
    TextBox18.Value = Format(CDbl(TextBox149.Value) - CDbl(TextBox17.Value), "0.0000")
    TextBox19.Value = Format(CDbl(TextBox13.Value) - CDbl(TextBox16.Value), "0.0000")
    TextBox14.Value = Format(CDbl(TextBox19.Value) * CDbl(TextBox9.Value), "0.0000")
    Me.EnableEvents = True
End Sub
 
Private Sub TextBox18_Change()
    If Me.EnableEvents = False Then Exit Sub
    Me.EnableEvents = False
    On Error Resume Next
    TextBox17.Value = Format(CDbl(TextBox149.Value) - CDbl(TextBox18.Value), "0.0000")
    TextBox16.Value = Format(CDbl(TextBox17.Value) * CDbl(TextBox20.Value), "0.0000")
    TextBox19.Value = Format(CDbl(TextBox13.Value) - CDbl(TextBox16.Value), "0.0000")
    TextBox14.Value = Format(CDbl(TextBox19.Value) * CDbl(TextBox9.Value), "0.0000")
    Me.EnableEvents = True
End Sub

Private Sub TextBox19_Change()
    If Me.EnableEvents = False Then Exit Sub
    Me.EnableEvents = False
    On Error Resume Next
    TextBox16.Value = Format(CDbl(TextBox13.Value) - CDbl(TextBox19.Value), "0.0000")
    TextBox17.Value = Format(CDbl(TextBox16.Value) / CDbl(TextBox20.Value), "0.0000")
    TextBox18.Value = Format(CDbl(TextBox149.Value) - CDbl(TextBox17.Value), "0.0000")
    TextBox14.Value = Format(CDbl(TextBox19.Value) * CDbl(TextBox9.Value), "0.0000")
    Me.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,094
Messages
6,128,785
Members
449,468
Latest member
AGreen17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top