ed.ayers315
Board Regular
- Joined
- Dec 14, 2009
- Messages
- 166
Hi folks,
I have tried numerous versions of the code below; some from this forum and some some the VBForums.
When I exit textbox177, I need the input to format to the Vessels c29 exactly. Then as seen below take that number and depending on the case selection do the correct math. The math seems to be working just fine. It is the orginal input that I continue to get screwed up.
Either the text box on the form does not show the correct format or the cell on the worksheet shows the wrong or no format, and somehow both.
I have 12 different combination of these on one form.
I have tried numerous versions of the code below; some from this forum and some some the VBForums.
When I exit textbox177, I need the input to format to the Vessels c29 exactly. Then as seen below take that number and depending on the case selection do the correct math. The math seems to be working just fine. It is the orginal input that I continue to get screwed up.
Either the text box on the form does not show the correct format or the cell on the worksheet shows the wrong or no format, and somehow both.
I have 12 different combination of these on one form.
Code:
Private Sub TextBox177_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim Prompt As String
Dim UserResp2 As String
Dim UR2 As Integer
If IsNumeric(TextBox177.Text) Then
If IsNumeric(TextBox177.Text) Then
If IsNumeric(TextBox177.Text) Then
Prompt = "1. This is your first choice" & vbCrLf & vbCrLf & "Press 1 for: Are you Titrating for ozs/Gal" & vbCrLf
Prompt = Prompt & "Press 2 for. Are you Titrating for %" & vbCrLf
UR2 = 0
While UR2 < 1 Or UR2 > 5
UserResp2 = InputBox(Prompt, "The Big Question")
UR2 = Val(UserResp2)
Wend
Select Case UR2
Case 1
' Do stuff for choice 1 here
TextBox173.Value = Round(CDbl(TextBox177.Value) * 7812.5, 0) & " PPM"
Sheets("VESSELS").Range("$c$29") = TextBox177
Sheets("VESSELS").Select
ActiveSheet.Unprotect
Range("$c$29").Select
Selection.NumberFormat = "General"
Range("$c$29").Select
Selection.NumberFormat = "#.0"" ozs/gal"""
ActiveSheet.Protect
'
Case 2
' Do stuff for choice 2 here
TextBox173.Value = Round(CDbl(TextBox177.Value) * 10000, 0) & " PPM"
Sheets("VESSELS").Range("$c$29") = TextBox177
Sheets("VESSELS").Select
ActiveSheet.Unprotect
Range("$c$29").Select
Selection.NumberFormat = "General"
Range("$c$29").Select
Selection.NumberFormat = "#.0"" %"""
ActiveSheet.Protect
'
End Select
End If
End If
End If
End Sub
Private Sub TextBox25_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim Prompt As String
Dim UserResp4 As String
Dim UR4 As Integer
If IsNumeric(TextBox25.Text) Then
If IsNumeric(TextBox25.Text) Then
If IsNumeric(TextBox25.Text) Then
Prompt = "1. This is your first choice" & vbCrLf & vbCrLf & "Press 1 for: Are you Titrating for ozs/Gal" & vbCrLf
Prompt = Prompt & "Press 2 for. Are you Titrating for %" & vbCrLf
UR4 = 0
While UR4 < 1 Or UR4 > 5
UserResp4 = InputBox(Prompt, "The Big Question")
UR4 = Val(UserResp4)
Wend
Select Case UR4
Case 1
' Do stuff for choice 1 here
TextBox53.Value = Round(CDbl(TextBox25.Value) * 7812.5, 0) & " PPM"
Sheets("VESSELS").Range("$c$42") = TextBox25
Sheets("VESSELS").Select
ActiveSheet.Unprotect
Range("C42").Select
Selection.NumberFormat = "General"
Selection.NumberFormat = "#.#"" ozs/gal"""
ActiveSheet.Protect
'
Case 2
' Do stuff for choice 2 here
TextBox53.Value = Round(CDbl(TextBox25.Value) * 10000, 0) & " PPM"
Sheets("VESSELS").Range("$c$42") = TextBox25
Sheets("VESSELS").Select
ActiveSheet.Unprotect
Range("C42").Select
Selection.NumberFormat = "General"
Selection.NumberFormat = "#.#"" %"""
ActiveSheet.Protect
'
End Select
End If
End If
End If
End Sub