Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am using the following code, it works fine with numbers but not with text,
can anyone help please Sub MixerTypeFilter() If Not UserForm7.ComboBox4.Text = "" Then 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 Not UCase(c.Value) < UserForm7.ComboBox4.Text 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 If End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Did yo try my change? Why are you using double negatives?
from If Not UCase(c.Value) < UserForm7.ComboBox4.Text Then to If UCase(c.Value) = UCase(UserForm7.ComboBox4.Text) Then "Miree" wrote: I am using the following code, it works fine with numbers but not with text, can anyone help please Sub MixerTypeFilter() If Not UserForm7.ComboBox4.Text = "" Then 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 Not UCase(c.Value) < UserForm7.ComboBox4.Text 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 If End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
im statement should change From:
Dim MyRange, MyRange1 As Range To: Dim MyRange As Range, MyRange1 As Range Otherwise MyRange is a variant. This: If Not UCase(c.Value) < UserForm7.ComboBox4.Text Then Equates to this: If UCase(c.Value) = UserForm7.ComboBox4.Text Then Maybe you want: If Not UCase(c.Value) = UserForm7.ComboBox4.Text Then You might have problems with this: Set MyRange1 = Union(MyRange1, c.EntireRow) I didn't test it, but since it would excede the row size limits, it could cause a problem. Outside those things, it looks OK. "Miree" wrote in message ... I am using the following code, it works fine with numbers but not with text, can anyone help please Sub MixerTypeFilter() If Not UserForm7.ComboBox4.Text = "" Then 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 Not UCase(c.Value) < UserForm7.ComboBox4.Text 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 If End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One mo
Sub MixerTypeFilter() Dim MyRange as range dim MyRange1 As Range dim c as range dim LastRow as long with sheets("FormulationsDatabase (2)") lastrow = .Cells(.Rows.Count, "DL").End(xlUp).Row set myrange = .range("DL1:DL" & lastrow end with If UserForm7.ComboBox4.Text < "" Then set myrange1 = nothing For Each c In MyRange.cells If UCase(c.Value) = ucase(UserForm7.ComboBox4.Text) Then If MyRange1 Is Nothing Then Set MyRange1 = c Else Set MyRange1 = Union(MyRange1, c) End If End If Next c If MyRange1 Is Nothing Then 'nothing found to delete else MyRange1.entirerow.Delete End If End If End Sub Miree wrote: I am using the following code, it works fine with numbers but not with text, can anyone help please Sub MixerTypeFilter() If Not UserForm7.ComboBox4.Text = "" Then 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 Not UCase(c.Value) < UserForm7.ComboBox4.Text 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 If End Sub -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I missed a closing paren:
set myrange = .range("DL1:DL" & lastrow should be: set myrange = .range("DL1:DL" & lastrow) Dave Peterson wrote: One mo Sub MixerTypeFilter() Dim MyRange as range dim MyRange1 As Range dim c as range dim LastRow as long with sheets("FormulationsDatabase (2)") lastrow = .Cells(.Rows.Count, "DL").End(xlUp).Row set myrange = .range("DL1:DL" & lastrow end with If UserForm7.ComboBox4.Text < "" Then set myrange1 = nothing For Each c In MyRange.cells If UCase(c.Value) = ucase(UserForm7.ComboBox4.Text) Then If MyRange1 Is Nothing Then Set MyRange1 = c Else Set MyRange1 = Union(MyRange1, c) End If End If Next c If MyRange1 Is Nothing Then 'nothing found to delete else MyRange1.entirerow.Delete End If End If End Sub Miree wrote: I am using the following code, it works fine with numbers but not with text, can anyone help please Sub MixerTypeFilter() If Not UserForm7.ComboBox4.Text = "" Then 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 Not UCase(c.Value) < UserForm7.ComboBox4.Text 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 If End Sub -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Works for number but not text | Excel Programming | |||
Works on numbers but not on TEXT | Excel Programming | |||
filter works on letters not numbers | Excel Discussion (Misc queries) | |||
Formula that works like text-to-column | Excel Worksheet Functions | |||
External link only works for numbers -- for text values, #N/A is displayed unless linked file is open | Links and Linking in Excel |