Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Stupid logic is messing up again... < = Statements crapping out...

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Stupid logic is messing up again... < = Statements crapping out...

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Stupid logic is messing up again... < = Statements crapping out...

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Logic Statements Chris Sear Excel Discussion (Misc queries) 2 July 21st 08 03:09 PM
"Reading"the logic behind too-long command statements Alex Excel Worksheet Functions 2 August 29th 06 08:12 PM
Excel Logic Statements Leach Excel Discussion (Misc queries) 2 April 26th 06 02:07 AM
Can you stop charts from plotting logic statements as 0 Newbeetle Charts and Charting in Excel 1 December 15th 04 10:34 AM
Logic Statements ehflam Excel Programming 3 November 23rd 04 09:43 PM


All times are GMT +1. The time now is 01:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"