Code not working for text

M

Miree

I am using the following code it works with numbers but not with text any
help would be much appreciated

Sub MixerTypeFilter()

If Not UserForm7.ComboBox4.Text = "" Then
Dim MyRange, MyRange1 As Range
Lastrow = Cells(Rows.Count, "DU").End(xlUp).Row
Set MyRange = Sheets("FormulationsDatabase (2)").Range("DU1:DU" & 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
 
R

Rob Wills

Hi,

I'm not sure what you're trying to achieve - so I don't quite understand
what you class as "not working"

However I did notice that you're variable declarations aren't specific (this
works in other languages - but not VB)

your line should read:
"Dim MyRange as range, MyRange1 As Range"

HTH's
 
M

Miree

What I am trying to achive is for each row which doesnt match(in the
specified column) what has been entered in text box is deleted. I got the
code from anothother post so don't fully understand it all myself.

Ultimately I want to be able to delete lines based on numbers, exact match
text and contains text. Any help would be much appreciated
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top