Hi All,
I've been scouring many different forums looking for code that works for me.
I have a multi-page userform, each with between 9 and 25 text boxes (it's a data entry interface)
I want there to be a text box that summarizes the scores that have been assigned to the criteria.
The code I'm currently using is:
and for the individual text boxes I use:
This works fine for me, but the biggest issue I have is that "NA" is one of the potential inputs. Entering anything except a numeric value instantly closes the userform. I would also prefer to keep using Textboxes instead of a ComboBox.
Is there a work around for this? Preferably, a way to assign a value of 0 to "NA" or to make the code completely ignore non-numeric values in the sum.
Thanks in advance!!
I've been scouring many different forums looking for code that works for me.
I have a multi-page userform, each with between 9 and 25 text boxes (it's a data entry interface)
I want there to be a text box that summarizes the scores that have been assigned to the criteria.
The code I'm currently using is:
Code:
Private Sub TextBoxesSum()
Dim Total As Double
Total = 0
If txtHabPIR.Value = n Then txtHabPIR.Value = 0
If Len(txtHabPIR.Value) > 0 Then Total = Total + CDbl(txtHabPIR.Value)
If Len(txtFishPIR.Value) > 0 Then Total = Total + CDbl(txtFishPIR.Value)
If Len(txtBirdPIR.Value) > 0 Then Total = Total + CDbl(txtBirdPIR.Value)
If Len(txtFaunaPIR.Value) > 0 Then Total = Total + CDbl(txtFaunaPIR.Value)
If Len(txtAquaPIR.Value) > 0 Then Total = Total + CDbl(txtAquaPIR.Value)
txtSummary5.Value = Total
End Sub
and for the individual text boxes I use:
Code:
Private Sub txtAquaPIR_Change()
TextBoxesSum
End Sub
This works fine for me, but the biggest issue I have is that "NA" is one of the potential inputs. Entering anything except a numeric value instantly closes the userform. I would also prefer to keep using Textboxes instead of a ComboBox.
Is there a work around for this? Preferably, a way to assign a value of 0 to "NA" or to make the code completely ignore non-numeric values in the sum.
Thanks in advance!!