Sorting or filtering for certain numbers

ChiTown

New Member
Joined
Mar 31, 2011
Messages
16
Hello all,

I'm using Excel 2007. I have a column called "Zipcodes" (which contain US zipcodes) which contain 55 different zipcodes. What is the quickest and best way to obtain them?

Say I want zipcodes:

90210
92541
90564
90851
98761

I was putting a filter on and looking ticking the checkbox of my desired zips but it can be time consuming that way. Is there a better/quicker way to handle them? Especially since a lot of the numbers are not in a range.

Thanks!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
I guess we can't edit our posts on the forum?

Is there a way I could paste the zipcodes I want as this would be very quick?
 
Upvote 0
Sorry but the reason that you haven't had a reply is because your question isn't at all clear.

What do you actually want to do?
 
Upvote 0
(Sorry VoG and thanks for at least replying to inform of my issue.)

I have a list of zip codes that are adjacent and non adjacent such as:

90210
90211
90212
92541
90564
90851
98761

Say I only want to see certain ones such as:

90212
90564
90851
98761

I was using the filter function and see that I had to manually tick the zips that I wanted however, there are 23 zips out of 55 that I want to show. (So the other 22 zips I want to hide).

Doing it the manual way is time intensive and error prone.

What is the best way to tell excel to only show me these zips (using the filter, pivot table, or anything other)?

Again I'm using 2007. Let me know if you need more info.

Thanks again!
 
Last edited:
Upvote 0
Maybe

Code:
Sub ShowZips()
Dim LR As Long, i As Long, j As Long
Dim s As String
Dim X
s = InputBox("Enter the list of zips separated by ,")
Application.ScreenUpdating = False
LR = Range("A" & Rows.Count).End(xlUp).Row
Rows(1 & ":" & LR).Hidden = True
X = Split(s, ",")
For i = 1 To LR
    For j = LBound(X) To UBound(X)
        If Range("A" & i).Value = Val(X(j)) Then
            Rows(i).Hidden = False
            Exit For
        End If
    Next j
Next i
End Sub
 
Upvote 0
VoG,

Thanks SO much for doing this for me.

I just learned about macros and recorded my first few the other day but never oped VBA to play with code. So your macro code was the first I've ever done!

After Googling for it I understand that code is made in "modules".

Thank you again for helping me with this. I wouldn't have been able code it as I'm not familiar with VBA language.
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,390
Members
452,909
Latest member
VickiS

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
Back
Top