Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
is there a way to format a cell so that you can put multiple values in it? for example
1,2,3,4
1,3,4
1
2
1,3then i can search for those values/ filter the values? thanks

I'm assuming you want to filter on an individual value, e.g. filtering on 3 would hide rows 3 and 4.
I don't know of a way to use Excel's AutoFilter feature with this type of data, but this macro will do something similiar, e.g. filtering on 3 will hide rows 3 and 4.
It includes code to Show All by default and will Show All and tell the user if the requested value is not found.
It does not however, present a list of unique values to choose from. That could be done, but it would take a bit more code...and time. ;-)
Sub FindVal()
Dim MyRange As Range
Set MyRange = Range("A1:A5")
'Get value from user
MyValue = Application.InputBox _
(Prompt:="Enter Value to Filter On, Click OK to Show All", _
Title:="Value Filter", _
Default:="Show All")
'Exit if user cancels
If MyValue = False Then Exit Sub
'Show All by default
If MyValue = "Show All" Then
MyRange.EntireRow.Hidden = False
Exit Sub
End If
'Make all rows visible then hide those without value
Range("A1:A5").EntireRow.Hidden = False
With MyRange
Set c = .Find(MyValue, lookat:=xlPart)
If Not c Is Nothing Then
For Each cell In MyRange
If Not cell Like "*" & MyValue & "*" _
Then cell.EntireRow.Hidden = True
Next
Exit Sub
Else
'Inform user if value not found
MsgBox MyValue & " Not Found"
End If
End With
End Sub

![]() |
Word 2003 and docs open s...
|
word document view
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |