+ Reply to Thread
Results 1 to 7 of 7

Filterin of Cities in addresses

Hybrid View

  1. #1
    Registered User
    Join Date
    04-22-2013
    Location
    Makati
    MS-Off Ver
    Excel 2007
    Posts
    3

    Filterin of Cities in addresses

    Hi,

    I am a newbie in excel. My problem is how to match and filter the cities in a list of address in Column B. There's about 14,500 list of addresses in one column and I need to identify which city needs to be excluded from the list in Column A. This is because these cities are affected by Typhoon Yolanda. Please see attached.

    I already tried vlookup but it doesn't provide the result I need.

    Please help. I have a deadline on this.

    Thanks.

    Benj
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Filterin of Cities in addresses

    Hi..

    Try this..

    The results are highlighted red in Sheet 1 and also copied to Sheet2..
    Option Compare Text
    Private Sub CommandButton1_Click()
        Dim r As Range
        Dim LR As Long
        Application.ScreenUpdating = False
        With CreateObject("VBScript.RegExp")
            .IgnoreCase = True
            .Pattern = "\b(Aklan|Antique|Capiz|Iloilo|Negros Occidental|Ormoc, Leyte|Coron, Palawan)\b"
            For Each r In Range(Cells(1, 2), Cells(Rows.Count, 2).End(xlUp))
                If .test(r.Value) = True Then
                    LR = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row + 1
                    Cells(r.Row, 1).EntireRow.Interior.ColorIndex = 3
                    Cells(r.Row, 2).Copy Destination:=Sheets("Sheet2").Range("A" & LR)
                End If
            Next r
        End With
        Sheets("Sheet2").Columns.AutoFit
        Application.ScreenUpdating = True
    End Sub
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    04-22-2013
    Location
    Makati
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Filterin of Cities in addresses

    Quote Originally Posted by apo View Post
    Hi..

    Try this..

    The results are highlighted red in Sheet 1 and also copied to Sheet2..
    Option Compare Text
    Private Sub CommandButton1_Click()
        Dim r As Range
        Dim LR As Long
        Application.ScreenUpdating = False
        With CreateObject("VBScript.RegExp")
            .IgnoreCase = True
            .Pattern = "\b(Aklan|Antique|Capiz|Iloilo|Negros Occidental|Ormoc, Leyte|Coron, Palawan)\b"
            For Each r In Range(Cells(1, 2), Cells(Rows.Count, 2).End(xlUp))
                If .test(r.Value) = True Then
                    LR = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row + 1
                    Cells(r.Row, 1).EntireRow.Interior.ColorIndex = 3
                    Cells(r.Row, 2).Copy Destination:=Sheets("Sheet2").Range("A" & LR)
                End If
            Next r
        End With
        Sheets("Sheet2").Columns.AutoFit
        Application.ScreenUpdating = True
    End Sub
    Thank you so much for the help. This would easily help us identify how may of our clients need help.

  4. #4
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 365
    Posts
    2,406

    Re: Filterin of Cities in addresses

    Maybe something like this? It's big file sorry


    Azumi
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    04-22-2013
    Location
    Makati
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Filterin of Cities in addresses

    Quote Originally Posted by azumi View Post
    Maybe something like this? It's big file sorry


    Azumi
    It helps a lot. Thank you for your quick reply. I appreciate it. this could help us easily identify the areas affected by typhoon and sort out the list of clients need help.

  6. #6
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Filterin of Cities in addresses

    Hi Azumi..

    When i ran your filter for the City of "AKLAN".. 2 out of the first 8 results don't seem correct..

    It looks like it has picked up the string "AKLAN" within other words..

    POBLACION BANGA MALAY WESTERN VISAYAS AKLAN 5608
    880 NEW BUSWANG KALIBO AKLAN
    DONGON WEST NUMANCIA WESTERN VISAYAS AKLAN 5604
    203 LOWER KALAKLAN RD. OLONGAPO ZAMBALES
    131 YAP MANOR POBLACION BANGA AKLAN
    SCUBA CHAMP STATION 1 BALABAG MALAY AKLAN
    LGU MALAY BALABAG MALAY WESTERN VISAYAS AKLAN 560
    SA GEMINI ST UPPER KALAKLAN OLONGAPO ZAMBALES

    I also noticed that when doing a Filter on the city of "Antique".. the following result came:
    162 RIZAL ST POBLACION ANTIQUERA CENTRAL VISAYAS

    Having said that.. I like the way you have set it out..

  7. #7
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 365
    Posts
    2,406

    Re: Filterin of Cities in addresses

    Yes sure, happy it works for you, and nice feedback

    Regards
    Azumi

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro to filter cities
    By rafuk73 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-31-2013, 09:56 AM
  2. Replies: 2
    Last Post: 10-19-2012, 12:23 PM
  3. Replies: 3
    Last Post: 05-28-2012, 03:52 PM
  4. Many Cities into few Regions
    By Johnny Image in forum Excel General
    Replies: 2
    Last Post: 04-17-2012, 07:25 PM
  5. Pivot Table - Sorting on Sum field and filterin
    By malkaf@walla.co.il in forum Excel General
    Replies: 0
    Last Post: 05-30-2006, 06:15 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1