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>