PC Review


Reply
Thread Tools Rate Thread

delete if contains

 
 
Miree
Guest
Posts: n/a
 
      20th Mar 2009
I curently have this macro which works fine, I now need to adapt it for
TextBox9 and only delete line if it does not contain words typed into text
box

Sub Filter()
Dim rng As Range
Dim i As Long

Set rng = ActiveSheet.Range(Cells(1, "DY"), Cells(Rows.Count, "DY").End(xlUp))

With rng
For i = .Rows.Count To 1 Step -1
If Not .Cells(i) = UserForm7.ComboBox2.Value Then
.Cells(i).EntireRow.Delete
End If
Next i
End With
End Sub

Any help pwill be much appreciated
Thanks
 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      20th Mar 2009
f Not .Cells(i) = UserForm7.TextBox9.Text Then
.Cells(i).EntireRow.Delete
End If

--
If this post helps click Yes
--
Jacob Skaria


 
Reply With Quote
 
Miree
Guest
Posts: n/a
 
      20th Mar 2009
This only works if the contents are exact i am looking to make it work if one
word is typed in to the text box it will find it if it appears anywhere in
the cell text

"Jacob Skaria" wrote:

> f Not .Cells(i) = UserForm7.TextBox9.Text Then
> .Cells(i).EntireRow.Delete
> End If
>
> --
> If this post helps click Yes
> --
> Jacob Skaria
>
>

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      20th Mar 2009
Dear Miree

User Instr function


If Instr(.Cells(i),UserForm7.TextBox9.Text) = 0 Then
.Cells(i).EntireRow.Delete
End If


If this post helps click Yes
--------------
Jacob Skaria


"Miree" wrote:

> This only works if the contents are exact i am looking to make it work if one
> word is typed in to the text box it will find it if it appears anywhere in
> the cell text
>
> "Jacob Skaria" wrote:
>
> > f Not .Cells(i) = UserForm7.TextBox9.Text Then
> > .Cells(i).EntireRow.Delete
> > End If
> >
> > --
> > If this post helps click Yes
> > --
> > Jacob Skaria
> >
> >

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      20th Mar 2009
Look at VBA's help for InStr.

It's like =find() or =Search() in excel.

Miree wrote:
>
> This only works if the contents are exact i am looking to make it work if one
> word is typed in to the text box it will find it if it appears anywhere in
> the cell text
>
> "Jacob Skaria" wrote:
>
> > f Not .Cells(i) = UserForm7.TextBox9.Text Then
> > .Cells(i).EntireRow.Delete
> > End If
> >
> > --
> > If this post helps click Yes
> > --
> > Jacob Skaria
> >
> >


--

Dave Peterson
 
Reply With Quote
 
Miree
Guest
Posts: n/a
 
      23rd Mar 2009
That works perfectly thanks, i have a slightly more complicated problem along
these lines and you help would once again be much appreciated

using the same code would it be possible to delete line if value is not
equal to or inbetween text boxes 5 and 6 (box 5 always being less or the same
as 6)

"Jacob Skaria" wrote:

> Dear Miree
>
> User Instr function
>
>
> If Instr(.Cells(i),UserForm7.TextBox9.Text) = 0 Then
> .Cells(i).EntireRow.Delete
> End If
>
>
> If this post helps click Yes
> --------------
> Jacob Skaria
>
>
> "Miree" wrote:
>
> > This only works if the contents are exact i am looking to make it work if one
> > word is typed in to the text box it will find it if it appears anywhere in
> > the cell text
> >
> > "Jacob Skaria" wrote:
> >
> > > f Not .Cells(i) = UserForm7.TextBox9.Text Then
> > > .Cells(i).EntireRow.Delete
> > > End If
> > >
> > > --
> > > If this post helps click Yes
> > > --
> > > Jacob Skaria
> > >
> > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete data in a linked Excel sheet using Access code or seql delete Rocky Microsoft Access External Data 9 26th Jun 2005 12:42 AM
Re: Macro to delete sheets and saves remaining file does not properly delete module gazornenplat Microsoft Excel Programming 0 22nd Jun 2005 01:12 AM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Microsoft Excel Programming 7 21st Jun 2005 05:16 PM
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below Annette Microsoft Excel Programming 2 21st Sep 2004 02:40 PM
Re: When I highlight a sentence to delete, Word won't let me. I have to backspace. How can I deleted selected text with my delete key? Bill Foley Microsoft Word Document Management 1 4th Feb 2004 11:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:38 PM.