filters rows cantaining a certain word

XiniX

Board Regular
Joined
May 1, 2002
Messages
57
I got a list of proverbs and i want to see only those proverbs containing a certain word. How can i make a filter which will do that?

Thank you...
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

royUK

Well-known Member
Joined
Jul 24, 2002
Messages
1,606
Sub Autofilter()
'
' Macro1 Macro
' Macro recorded 18/10/2002 by Roy Cox
'

'
Selection.Autofilter
ActiveWindow.ScrollColumn = 1
Selection.Autofilter Field:=1, Criteria1:="Your Word"
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3

End Sub

This might work.
 

attc

Board Regular
Joined
Oct 11, 2002
Messages
87
for a non-macro based approach, you can also try putting this formula in the column next to your column of proverbs:

=1-ISERROR(FIND("slings and arrows",A1))

Then you can filter on that column.
 

XiniX

Board Regular
Joined
May 1, 2002
Messages
57
Thank you, so fast an answer..

I want "Your word" put dynamically in the macro. So that the macro askes for the word to filter...

Is that possible?
 

rikrak

Active Member
Joined
Aug 21, 2002
Messages
255
On 2002-10-27 09:00, XiniX wrote:
Thank you, so fast an answer..

I want "Your word" put dynamically in the macro. So that the macro askes for the word to filter...

Is that possible?

Hi,

Maybe you can use this macro.
It will show only the rows that contain a specified word.
<pre>
Sub Filter()
Dim searchString As String
Dim found As Range
Dim unionRng As Range

'get string to search
searchString = InputBox("Filter what?", "Filter", "")
If searchString = "" Then Exit Sub

' remove any filters
ActiveSheet.AutoFilterMode = False
' unhide all
saveCellPos = ActiveCell.Address
Cells.Select
Selection.EntireRow.Hidden = False

Set found = Cells.Find(searchString)
If Not found Is Nothing Then
FirstAddress = found.Address
Set unionRng = found
Do
Set found = Cells.FindNext(After:=found)
If found.Address = FirstAddress Then Exit Do
Set unionRng = union(found, unionRng)
Loop

'show only 'rows' containing searchstring
Cells.Select
Selection.EntireRow.Hidden = True
unionRng.EntireRow.Hidden = False
Else
MsgBox searchString & " not found!"
End If
Range(saveCellPos).Select
Set unionRng = Nothing
Set found = Nothing
End Sub
</pre>
 

Forum statistics

Threads
1,144,438
Messages
5,724,361
Members
422,546
Latest member
KevinOnTheDaily

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top