Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default = Greater than or Equal to Not working



I have a short code to search column C ina sheet for Numerical values as
below:

Private Sub TextBox1_Change()
If IsNumeric(TextBox1.Value) = False Then TextBox1.Value = ""
If TextBox1.Value < "" Then
ListBox1.Clear
ListBox2.Clear
ListBox3.Clear
ListBox1.AddItem "Solid Woven"
ListBox1.AddItem "Rubber Ply"
ListBox1.AddItem "Steel Cord"
Dim LastCell As Long
Dim myrow As Long
LastCell = Worksheets("InspectionData").Cells(Rows.Count, "C").End(xlUp).Row
With ActiveWorkbook.Worksheets("InspectionData")
..Select
For myrow = 1 To LastCell
If .Cells(myrow, 3) < "" And .Cells(myrow, 3).Value < 0 Then
If IsNumeric(.Cells(myrow, 3)) = True Then
ListBox3.AddItem Cells(myrow, 3)
End If
End If
Next
End With


It works great, but i need to add a condition so that ONLY values (=) to
the value in Textbox1 is shown in Listbox3.
But as below, when i add that section of code highlighted, i get NO values
at all.


If IsNumeric(TextBox1.Value) = False Then TextBox1.Value = ""
If TextBox1.Value < "" Then
ListBox1.Clear
ListBox2.Clear
ListBox3.Clear
ListBox1.AddItem "Solid Woven"
ListBox1.AddItem "Rubber Ply"
ListBox1.AddItem "Steel Cord"
Dim LastCell As Long
Dim myrow As Long
LastCell = Worksheets("InspectionData").Cells(Rows.Count, "C").End(xlUp).Row
With ActiveWorkbook.Worksheets("InspectionData")
..Select
For myrow = 1 To LastCell
If .Cells(myrow, 3) < "" And .Cells(myrow, 3).Value < 0 Then
If IsNumeric(.Cells(myrow, 3)) = True And .Cells(myrow, 3).Value =
TextBox1.Value Then ' <==== THIS BIT HERE
ListBox3.AddItem Cells(myrow, 3)
End If
End If
Next
End With
End If
End Sub


How can i sucessfully add that condition so it WILL work?


Corey....



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default = Greater than or Equal to Not working

Hi,

Textboxes return text so you must look at val(Textbo....etc.
Try this

Private Sub TextBox1_Change()
If IsNumeric(TextBox1.Value) = False Then TextBox1.Value = ""
If TextBox1.Value < "" Then
ListBox1.Clear
ListBox2.Clear
ListBox3.Clear
ListBox1.AddItem "Solid Woven"
ListBox1.AddItem "Rubber Ply"
ListBox1.AddItem "Steel Cord"
Dim LastCell As Long
Dim myrow As Long
Stop
LastCell = Worksheets("InspectionData").Cells(Rows.Count,
"C").End(xlUp).Row
With ActiveWorkbook.Worksheets("InspectionData")
For myrow = 1 To LastCell
If .Cells(myrow, 3) < "" And .Cells(myrow, 3).Value < 0 Then
If IsNumeric(.Cells(myrow, 3)) And .Cells(myrow, 3).Value =
Val(TextBox1.Value) Then ' <==== THIS BIT HERE
ListBox3.AddItem Cells(myrow, 3)
End If
End If
Next
End With
End If
End Sub

Mike


"Corey ...." wrote:



I have a short code to search column C ina sheet for Numerical values as
below:

Private Sub TextBox1_Change()
If IsNumeric(TextBox1.Value) = False Then TextBox1.Value = ""
If TextBox1.Value < "" Then
ListBox1.Clear
ListBox2.Clear
ListBox3.Clear
ListBox1.AddItem "Solid Woven"
ListBox1.AddItem "Rubber Ply"
ListBox1.AddItem "Steel Cord"
Dim LastCell As Long
Dim myrow As Long
LastCell = Worksheets("InspectionData").Cells(Rows.Count, "C").End(xlUp).Row
With ActiveWorkbook.Worksheets("InspectionData")
..Select
For myrow = 1 To LastCell
If .Cells(myrow, 3) < "" And .Cells(myrow, 3).Value < 0 Then
If IsNumeric(.Cells(myrow, 3)) = True Then
ListBox3.AddItem Cells(myrow, 3)
End If
End If
Next
End With


It works great, but i need to add a condition so that ONLY values (=) to
the value in Textbox1 is shown in Listbox3.
But as below, when i add that section of code highlighted, i get NO values
at all.


If IsNumeric(TextBox1.Value) = False Then TextBox1.Value = ""
If TextBox1.Value < "" Then
ListBox1.Clear
ListBox2.Clear
ListBox3.Clear
ListBox1.AddItem "Solid Woven"
ListBox1.AddItem "Rubber Ply"
ListBox1.AddItem "Steel Cord"
Dim LastCell As Long
Dim myrow As Long
LastCell = Worksheets("InspectionData").Cells(Rows.Count, "C").End(xlUp).Row
With ActiveWorkbook.Worksheets("InspectionData")
..Select
For myrow = 1 To LastCell
If .Cells(myrow, 3) < "" And .Cells(myrow, 3).Value < 0 Then
If IsNumeric(.Cells(myrow, 3)) = True And .Cells(myrow, 3).Value =
TextBox1.Value Then ' <==== THIS BIT HERE
ListBox3.AddItem Cells(myrow, 3)
End If
End If
Next
End With
End If
End Sub


How can i sucessfully add that condition so it WILL work?


Corey....




  #3   Report Post  
Posted to microsoft.public.excel.programming
ctm ctm is offline
external usenet poster
 
Posts: 10
Default = Greater than or Equal to Not working

I will have a look at it when back on Monday.
Thank you for your reply Mike.
I am confident that was the error in the code.

Corey....
"Mike H" wrote in message
...
Hi,

Textboxes return text so you must look at val(Textbo....etc.
Try this

Private Sub TextBox1_Change()
If IsNumeric(TextBox1.Value) = False Then TextBox1.Value = ""
If TextBox1.Value < "" Then
ListBox1.Clear
ListBox2.Clear
ListBox3.Clear
ListBox1.AddItem "Solid Woven"
ListBox1.AddItem "Rubber Ply"
ListBox1.AddItem "Steel Cord"
Dim LastCell As Long
Dim myrow As Long
Stop
LastCell = Worksheets("InspectionData").Cells(Rows.Count,
"C").End(xlUp).Row
With ActiveWorkbook.Worksheets("InspectionData")
For myrow = 1 To LastCell
If .Cells(myrow, 3) < "" And .Cells(myrow, 3).Value < 0 Then
If IsNumeric(.Cells(myrow, 3)) And .Cells(myrow, 3).Value =
Val(TextBox1.Value) Then ' <==== THIS BIT HERE
ListBox3.AddItem Cells(myrow, 3)
End If
End If
Next
End With
End If
End Sub

Mike


"Corey ...." wrote:



I have a short code to search column C ina sheet for Numerical values as
below:

Private Sub TextBox1_Change()
If IsNumeric(TextBox1.Value) = False Then TextBox1.Value = ""
If TextBox1.Value < "" Then
ListBox1.Clear
ListBox2.Clear
ListBox3.Clear
ListBox1.AddItem "Solid Woven"
ListBox1.AddItem "Rubber Ply"
ListBox1.AddItem "Steel Cord"
Dim LastCell As Long
Dim myrow As Long
LastCell = Worksheets("InspectionData").Cells(Rows.Count,
"C").End(xlUp).Row
With ActiveWorkbook.Worksheets("InspectionData")
..Select
For myrow = 1 To LastCell
If .Cells(myrow, 3) < "" And .Cells(myrow, 3).Value < 0 Then
If IsNumeric(.Cells(myrow, 3)) = True Then
ListBox3.AddItem Cells(myrow, 3)
End If
End If
Next
End With


It works great, but i need to add a condition so that ONLY values (=) to
the value in Textbox1 is shown in Listbox3.
But as below, when i add that section of code highlighted, i get NO
values
at all.


If IsNumeric(TextBox1.Value) = False Then TextBox1.Value = ""
If TextBox1.Value < "" Then
ListBox1.Clear
ListBox2.Clear
ListBox3.Clear
ListBox1.AddItem "Solid Woven"
ListBox1.AddItem "Rubber Ply"
ListBox1.AddItem "Steel Cord"
Dim LastCell As Long
Dim myrow As Long
LastCell = Worksheets("InspectionData").Cells(Rows.Count,
"C").End(xlUp).Row
With ActiveWorkbook.Worksheets("InspectionData")
..Select
For myrow = 1 To LastCell
If .Cells(myrow, 3) < "" And .Cells(myrow, 3).Value < 0 Then
If IsNumeric(.Cells(myrow, 3)) = True And .Cells(myrow, 3).Value
=

TextBox1.Value Then ' <==== THIS BIT HERE
ListBox3.AddItem Cells(myrow, 3)
End If
End If
Next
End With
End If
End Sub


How can i sucessfully add that condition so it WILL work?


Corey....






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
Greater/Less Than or Equal To Hoov Excel Discussion (Misc queries) 5 May 14th 09 05:54 PM
IF with Equal to or Greater than sonicj Excel Discussion (Misc queries) 4 May 1st 08 09:02 PM
Greater Than/Equal To Formula Millington Excel Discussion (Misc queries) 4 June 17th 07 04:51 AM
Greater than or equal to (Plus or minus) Brandon Excel Discussion (Misc queries) 2 July 18th 06 11:34 PM
Vlookup but also equal to and greater than? dazman Excel Worksheet Functions 1 August 7th 05 05:59 PM


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

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

About Us

"It's about Microsoft Excel"