ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If statements (https://www.excelbanter.com/excel-programming/422813-re-if-statements.html)

Miree

If statements
 
Although it is a text box it will be numbers entered

"Bob Phillips" wrote:

Less than or more than with text?

--
__________________________________
HTH

Bob

"Miree" wrote in message
...
I have the following code, i need to alter it now for some other user
inputs
I know i need to change the line
If UCase(c.Value) < UserForm7.TextBox1.Value Then
I need to be able to put , less than one text box and more than another(if
possible ignoring an empty box)
Also if possible i need to just look in the cell to see if it partially
contains what is is text box

Thank you

Sub TSRFilter()
Dim MyRange, MyRange1 As Range
lastrow = Cells(Rows.Count, "DL").End(xlUp).Row
Set MyRange = Sheets("FormulationsDatabase (2)").Range("DL1:DL" & lastrow)
For Each c In MyRange
If UCase(c.Value) < UserForm7.TextBox1.Value Then
If MyRange1 Is Nothing Then
Set MyRange1 = c.EntireRow
Else
Set MyRange1 = Union(MyRange1, c.EntireRow)
End If
End If
Next
If Not MyRange1 Is Nothing Then
MyRange1.Delete
End If

End Sub





Bob Phillips[_3_]

If statements
 
Then why are you upcase'ing it?

You can test a textbox value with

Val(UserForm7.TextBox1.Text)


and

< Val(UserForm7.TextBox1.Text)

--
__________________________________
HTH

Bob

"Miree" wrote in message
...
Although it is a text box it will be numbers entered

"Bob Phillips" wrote:

Less than or more than with text?

--
__________________________________
HTH

Bob

"Miree" wrote in message
...
I have the following code, i need to alter it now for some other user
inputs
I know i need to change the line
If UCase(c.Value) < UserForm7.TextBox1.Value Then
I need to be able to put , less than one text box and more than
another(if
possible ignoring an empty box)
Also if possible i need to just look in the cell to see if it partially
contains what is is text box

Thank you

Sub TSRFilter()
Dim MyRange, MyRange1 As Range
lastrow = Cells(Rows.Count, "DL").End(xlUp).Row
Set MyRange = Sheets("FormulationsDatabase (2)").Range("DL1:DL" &
lastrow)
For Each c In MyRange
If UCase(c.Value) < UserForm7.TextBox1.Value Then
If MyRange1 Is Nothing Then
Set MyRange1 = c.EntireRow
Else
Set MyRange1 = Union(MyRange1, c.EntireRow)
End If
End If
Next
If Not MyRange1 Is Nothing Then
MyRange1.Delete
End If

End Sub








All times are GMT +1. The time now is 12:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com