Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello! I am having issues with the following code...It seems that my
statment below isn't working the way it should. Here is the situation... THE < ans, ans, = ans is the problem. I need the code to only match the TRUE completed value of TextBox3... I applogize how disorganized this appears but there is no better way to present it. COMPLETED CODE Private Sub CommandButton1_Click() On Error GoTo nogood ans = TextBox3.Value '================================vvvvvv====== If Sheet1.Range("datacorrect").Find(ans).Row < ans Then '================================^^^^^^^====== MsgBox "OK" Unload Me Exit Sub End If nogood: MsgBox "Information Incorrect...Please try again." Userform1.Show End Sub SITUATION 1 [ ans ] -- Partial Information Completes Macro '================================vvvvvv====== If Sheet1.Range("datacorrect").Find(ans).Row < ans Then '================================^^^^^^^====== Situation: If the person types the first few characters but not the true value of the range it still completes the macro even though the answer is wrong. The named range "datacorrect" only lists "booking" in this instance but it will complete the macro if someone types "boo" in Textbox1. SITUATION 2 [ < ans ] -- Anything typed in fails '================================vvvvvv====== If Sheet1.Range("datacorrect").Find(ans).Row ans Then '================================^^^^^^^====== Situation: If the person types any thing in it wont complete the macro and sends them straight to "NOGOOD: EVENT" SITUATION 2 [ = ans ] -- Anything typed in fails '================================vvvvvv====== If Sheet1.Range("datacorrect").Find(ans).Row = ans Then '================================^^^^^^^====== Situation: If the person types any thing in it wont complete the macro and sends them straight to "NOGOOD: EVENT" |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Not sure what you are trying to do.
You code says: If the row number where the string variable ans is found is less than the the string variable ans, then.... Depending what you are entering in TextBox3, you have something like If 10 < "some string" Then.. What do you expect that to evaluate to ? Possibly you mean: If Sheet1.Range("datacorrect").Find(ans).Row < CLng(ans) Then.... NickHK wrote in message ups.com... Hello! I am having issues with the following code...It seems that my statment below isn't working the way it should. Here is the situation... THE < ans, ans, = ans is the problem. I need the code to only match the TRUE completed value of TextBox3... I applogize how disorganized this appears but there is no better way to present it. COMPLETED CODE Private Sub CommandButton1_Click() On Error GoTo nogood ans = TextBox3.Value '================================vvvvvv====== If Sheet1.Range("datacorrect").Find(ans).Row < ans Then '================================^^^^^^^====== MsgBox "OK" Unload Me Exit Sub End If nogood: MsgBox "Information Incorrect...Please try again." Userform1.Show End Sub SITUATION 1 [ ans ] -- Partial Information Completes Macro '================================vvvvvv====== If Sheet1.Range("datacorrect").Find(ans).Row < ans Then '================================^^^^^^^====== Situation: If the person types the first few characters but not the true value of the range it still completes the macro even though the answer is wrong. The named range "datacorrect" only lists "booking" in this instance but it will complete the macro if someone types "boo" in Textbox1. SITUATION 2 [ < ans ] -- Anything typed in fails '================================vvvvvv====== If Sheet1.Range("datacorrect").Find(ans).Row ans Then '================================^^^^^^^====== Situation: If the person types any thing in it wont complete the macro and sends them straight to "NOGOOD: EVENT" SITUATION 2 [ = ans ] -- Anything typed in fails '================================vvvvvv====== If Sheet1.Range("datacorrect").Find(ans).Row = ans Then '================================^^^^^^^====== Situation: If the person types any thing in it wont complete the macro and sends them straight to "NOGOOD: EVENT" |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Actually found out that if I do
ans = "13" & TextBox3.Value & "13" If Sheet1.Range("datacorrect").Find(ans).Row < ans Then It works the way I wanted it to...I figure the problem was it wasn't searching the entire contents for whatever reason...since there is a 13 before and after the value it will not bother to search for 13boo13 because it wouldn't exsist but if its typed in the spreadsheet as 13booking13 it works fine...just sorta came to me before i called it quits for the night...Thanks for your input though! -Todd NickHK wrote: Not sure what you are trying to do. You code says: If the row number where the string variable ans is found is less than the the string variable ans, then.... Depending what you are entering in TextBox3, you have something like If 10 < "some string" Then.. What do you expect that to evaluate to ? Possibly you mean: If Sheet1.Range("datacorrect").Find(ans).Row < CLng(ans) Then.... NickHK wrote in message ups.com... Hello! I am having issues with the following code...It seems that my statment below isn't working the way it should. Here is the situation... THE < ans, ans, = ans is the problem. I need the code to only match the TRUE completed value of TextBox3... I applogize how disorganized this appears but there is no better way to present it. COMPLETED CODE Private Sub CommandButton1_Click() On Error GoTo nogood ans = TextBox3.Value '================================vvvvvv====== If Sheet1.Range("datacorrect").Find(ans).Row < ans Then '================================^^^^^^^====== MsgBox "OK" Unload Me Exit Sub End If nogood: MsgBox "Information Incorrect...Please try again." Userform1.Show End Sub SITUATION 1 [ ans ] -- Partial Information Completes Macro '================================vvvvvv====== If Sheet1.Range("datacorrect").Find(ans).Row < ans Then '================================^^^^^^^====== Situation: If the person types the first few characters but not the true value of the range it still completes the macro even though the answer is wrong. The named range "datacorrect" only lists "booking" in this instance but it will complete the macro if someone types "boo" in Textbox1. SITUATION 2 [ < ans ] -- Anything typed in fails '================================vvvvvv====== If Sheet1.Range("datacorrect").Find(ans).Row ans Then '================================^^^^^^^====== Situation: If the person types any thing in it wont complete the macro and sends them straight to "NOGOOD: EVENT" SITUATION 2 [ = ans ] -- Anything typed in fails '================================vvvvvv====== If Sheet1.Range("datacorrect").Find(ans).Row = ans Then '================================^^^^^^^====== Situation: If the person types any thing in it wont complete the macro and sends them straight to "NOGOOD: EVENT" |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Logic Statements | Excel Discussion (Misc queries) | |||
"Reading"the logic behind too-long command statements | Excel Worksheet Functions | |||
Excel Logic Statements | Excel Discussion (Misc queries) | |||
Can you stop charts from plotting logic statements as 0 | Charts and Charting in Excel | |||
Logic Statements | Excel Programming |