Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

StackOverflow Point

StackOverflow Point Navigation

  • Web Stories
  • Badges
  • Tags
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Web Stories
  • Badges
  • Tags
Home/ Questions/Q 2129
Alex Hales
  • 0
Alex HalesTeacher
Asked: May 31, 20222022-05-31T15:47:53+00:00 2022-05-31T15:47:53+00:00

excel – comparing numeric values in a userform or cell range

  • 0

[ad_1]

I am working on controls for my userform. Basically, I am trying to compare the value entered in a textbox (cbofalk) to a value in a range. If it exceeds the number in that range, then it comes up with a msg box yes/no type of decision. I am driving myself crazy because I cannot for the life of me get it to work. I have scoured this forum and the solutions I have implemented all result in the same issue. I even set up a reference box (falkuclone) just to see if I was appropriately addressing the range (since I am a newb)…it pulls the number I want to look at into the reference box, but when I try to compare that number, or even that range to cbofalk, it just doesn’t understand. I enter 10 into cbofalk and the number to exceed is 8.69 and it just merrily continues without the msgbox? The cell I am trying to reference (“J2”), contains a reference to a cell in a query table, but other than that I can’t think of any oddity surrounding this. I have tried adding Val, doing CInt and even CLng to make sure I am comparing apples to apples, but with the same issue. It just doesn’t flag the msgbox. Here is my original code surrounding the issue:

'code to flag a value outside of the control limits

'looks at value in falkuclone textbox and compares with cobfalk textbox and, if cbofalk is greater, triggers messagebox yes/no.
If Me.cboFalk.Value > falkuclone.Value Then
'message box yes/no logic
messageresult = MsgBox("Your falk value is out of specification. Would you like to enter anyways?", vbYesNo + vbCritical, "Out of Spec")

End If

If messageresult = vbNo Then

    Exit Sub
    
    Else

    'copy the data to the database
With ws
  .Cells(lRow, 1).Value = Me.cboFalk.Value
  .Cells(lRow, 2).Value = Me.cboTalk.Value
  .Cells(lRow, 3).Value = Me.cboTemp.Value
  .Cells(lRow, 4).Value = Me.cbopH.Value
  .Cells(lRow, 5).Value = Me.cboPSI.Value
  .Cells(lRow, 6).Value = Me.cboDate.Value

hiddenstageone_Click
End With

'clear the userform fields
Me.cboFalk.Value = ""
Me.cboTalk.Value = ""
Me.cboTemp.Value = ""
Me.cbopH.Value = ""
Me.cboPSI.Value = ""
Me.cboFalk.SetFocus

Exit Sub

End If


End Sub


Private Sub UserForm_Activate()

'make the form generate todays date when displayed
Me.cboDate.Value = Format(Now(), "mm/dd/yyyy")
'set the falkuclone textbox to equal J2 value when the userform is pulled up
falkuclone.Value = Sheets("Stage 1").Range("J2").Value


End Sub

Thanks so much for any help.

[ad_2]

  • 0 0 Answers
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Related Questions

  • xcode - Can you build dynamic libraries for iOS and ...

    • 0 Answers
  • bash - How to check if a process id (PID) ...

    • 5253 Answers
  • database - Oracle: Changing VARCHAR2 column to CLOB

    • 1098 Answers
  • What's the difference between HEAD, working tree and index, in ...

    • 1047 Answers
  • Amazon EC2 Free tier - how many instances can I ...

    • 0 Answers

Stats

  • Questions : 43k

Subscribe

Login

Forgot Password?

Footer

Follow

© 2022 Stackoverflow Point. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.