Histteacher
New Member
- Joined
- Jul 30, 2015
- Messages
- 2
Excel 2013
Issue: the first textbox value is compared to if it is greater than the total value of textbox 2. The issue is, only the first number (left to right) of each box is evaluated...likely reading it as a text.
Suggestions?
The closest posting I have found is here: http://www.mrexcel.com/forum/excel-questions/311520-visual-basic-applications-interesting-problem-100-not-greater-than-39-a.html
Issue: the first textbox value is compared to if it is greater than the total value of textbox 2. The issue is, only the first number (left to right) of each box is evaluated...likely reading it as a text.
Suggestions?
The closest posting I have found is here: http://www.mrexcel.com/forum/excel-questions/311520-visual-basic-applications-interesting-problem-100-not-greater-than-39-a.html
Code:
Private Sub CommandButton1_Click()
Dim NextRow As Long
'Make sure Sheet1 is active
Sheets("Sheet1").Activate
'Make sure Objective 1 Score is entered as number
If IsNumeric(tbObj1_Score.Value) Or tbObj1_Score.Value = "" Then
tbObj1_Score.Value = tbObj1_Score.Value
Else
MsgBox "You must enter a numeric value for the score."
tbObj1_Score.SetFocus
Exit Sub
End If
'Make sure Objective 1 Total is entered as number
If IsNumeric(tbObj1_Total.Value) Or tbObj1_Total.Value = "" Then
tbObj1_Total.Value = tbObj1_Total.Value
Else
MsgBox "You must enter a numeric value for the score."
tbObj1_Total.SetFocus
Exit Sub
End If
'Here is my error!!! VBA appears to only read the first number of each object,
'therefore it shows an error message for 8 > 10.
'Make sure Objective 1 Total Points is entered if there is a score in Obj 1 Score
If tbObj1_Score.Value > tbObj1_Total.Value = True Then
MsgBox "2222 Total possible points as a numeric value greater than the possible points."
tbObj1_Total.SetFocus
Exit Sub
End If
'Determine the next empty row
NextRow = Application.WorksheetFunction.CountA(Range("A:A")) + 1
'Transfer Objective 1 Score
Cells(NextRow, 1) = tbObj1_Score.Value
'Transfer Objective 1 Total Points
Cells(NextRow, 2) = tbObj1_Total.Value
'Unload and close
Unload UserForm1
Sheets("Sheet1").Select
End Sub