I have a userform where values in TextBoxes are used in calculations for other textboxes.
I use the following code to do this.
Private Sub CBCHOOOSE_Click()
Dim GM1 As Long
Dim GALY As Long
Dim GTLY As Long
Dim GLLY As Long
With Sheets("Margins")
.Unprotect
With UserForm2
GM1 = CLng(.TextBox2.Value)
GALY = CLng(.TextBox1.Value)
GTLY = CLng(.TextBox4.Value)
GLLY = CLng(.TextBox5.Value)
.TextBox6.Value = GM1 / GALY * GTLY
.TextBox7.Value = GM1 / GALY * GLLY
GM1 = CLng(TextBox3.Value)
.TextBox8.Value = GM1 / GALY * GTLY
.TextBox9.Value = GM1 / GALY * GLLY
End With
End Sub
My problem is that TextBox2 has a value of ".46" but GM1 has a value of 0 and the other G values are either 0 or 1 The calculated values are all zeros
What can be going wrong?
Bookmarks