+ Reply to Thread
Results 1 to 23 of 23

Excel 2007 : Partial matching cells with locations

Hybrid View

james1911 Partial matching cells with... 03-21-2011, 06:36 AM
royUK Re: Partial matching cells... 03-21-2011, 06:46 AM
DonkeyOte Re: Partial matching cells... 03-21-2011, 06:56 AM
james1911 Re: Partial matching cells... 03-21-2011, 07:07 AM
DonkeyOte Re: Partial matching cells... 03-21-2011, 07:24 AM
james1911 Re: Partial matching cells... 03-21-2011, 06:59 AM
james1911 Re: Partial matching cells... 03-22-2011, 07:46 AM
DonkeyOte Re: Partial matching cells... 03-22-2011, 08:00 AM
james1911 Re: Partial matching cells... 03-22-2011, 11:10 AM
DonkeyOte Re: Partial matching cells... 03-22-2011, 12:39 PM
james1911 Re: Partial matching cells... 03-22-2011, 12:44 PM
DonkeyOte Re: Partial matching cells... 03-22-2011, 01:18 PM
DonkeyOte Re: Partial matching cells... 03-22-2011, 02:01 PM
james1911 Re: Partial matching cells... 03-22-2011, 01:34 PM
james1911 Re: Partial matching cells... 03-23-2011, 07:04 AM
shg Re: Partial matching cells... 03-23-2011, 11:51 AM
Colin Legg Re: Partial matching cells... 05-08-2011, 03:29 PM
james1911 Re: Partial matching cells... 06-13-2011, 04:56 AM
  1. #1
    Registered User
    Join Date
    03-21-2011
    Location
    London,England
    MS-Off Ver
    Excel 2007
    Posts
    22

    Partial matching cells with locations

    Hi,

    I tried a lot to find an answer to this but this seems like a tricky probleum.

    I have a set of keywords which have locations( something like "jobs in London") in them in column B and set of all locations in the UK (London, Manchester, South East etc) in Column A.

    All I want to do is find all the keywords in column B that may have any of the Location terms in Column A. IF I do a partial string match with "Vlookup" it just just shows me the first instance of the location keyword.

    It will be good if I can find a formula or macro that will highlight all the keywords in Column B which have any of the locations in Column A.

    Thanks in advance for your help

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Partial matching cells with locations

    Why not just AutoFilter?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Partial matching cells with locations

    You could use a Conditional Format - if we assume A1:A10 hold Locations then having highlighted B1:Bn (where n is last row of strings) apply the following formula based Rule:

    =LOOKUP(9.99E+307,SEARCH(INDEX(" "&$A$1:$A$10&REPT("ZZZZ",$A$1:$A$10="")&" ",0)," "&$B1&" "))
    set format accordingly
    The above will then highlight all strings in B that contain one or more locations as listed in A

    (the above assumes space delimited strings - modify as necessary)

  4. #4
    Registered User
    Join Date
    03-21-2011
    Location
    London,England
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Partial matching cells with locations

    Hi DonkeyOte

    I think this might help. can you please explain some steps. Should i put this formulae in column C

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Partial matching cells with locations

    As outlined the suggestion related to Conditional Formatting.

    If you want to put in C you can do though you might want to wrap an ISNUMBER test around the formula - result of TRUE means 1+ locations found.
    (without the ISNUMBER test: any number = location found - #N/A means not found)

  6. #6
    Registered User
    Join Date
    03-21-2011
    Location
    London,England
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Partial matching cells with locations

    Thanks for all your help. One last thing can I please have the column number of the string next to the results, just to check which location is in which keyword. Please note that some locations can be in more than 1 keyword

  7. #7
    Registered User
    Join Date
    03-21-2011
    Location
    London,England
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Partial matching cells with locations

    Thanks for changing the title roy. I am not sure how autofilter will help can you please explain in detail.

  8. #8
    Registered User
    Join Date
    03-21-2011
    Location
    London,England
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Partial matching cells with locations

    I am really sorry about this. I am uploading the file here for better clarity

    http://www.sendspace.com/file/j26r8b

    Keywords driving traffic to ur site are in column A and all Locations are in column B. All we want to do is find all the keywords in Column A which might have any location in Column B. The probleum we face is that during partail match through Isnumber, lookup, Vlookup etc. a keyword is matched with location even if that locations is just a strig "inside that word" ex keyword "Reed" is matched as a location because it exists inside "breedenbroek" though Reed is not a location.

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Partial matching cells with locations

    If you have a file to upload please do so here directly

    Quote Originally Posted by FAQ

    To attach a file to your post, you need to be using the main 'New Post' or 'New Thread' page and not 'Quick Reply'.

    To use the main 'New Post' page, click the 'Post Reply' button in the relevant thread.

    On this page, below the message box, you will find a button labelled 'Manage Attachments'.

    Clicking this button will open a new window for uploading attachments.

    You can upload an attachment either from your computer or from another URL by using the appropriate box on this page.
    Alternatively you can click the Attachment Icon to open this page.

    To upload a file from your computer, click the 'Browse' button and locate the file.

    To upload a file from another URL, enter the full URL for the file in the second box on this page.
    Once you have completed one of the boxes, click 'Upload'.

    Once the upload is completed the file name will appear below the input boxes in this window.

    You can then close the window to return to the new post screen.

  10. #10
    Registered User
    Join Date
    03-21-2011
    Location
    London,England
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Partial matching cells with locations

    Here is the file mate. Its Help.xlsx. Kindly have a look

    Thanks for your help in advance

  11. #11
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Partial matching cells with locations

    No attachment.

  12. #12
    Registered User
    Join Date
    03-21-2011
    Location
    London,England
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Partial matching cells with locations

    Please find the attached file
    Attached Files Attached Files

  13. #13
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Partial matching cells with locations

    With that much data (>18k locations to search for per keyword and >23k keywords) I would advise against a formula driven solution - is VBA viable ?

  14. #14
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Partial matching cells with locations

    OK - I am looking at this but might not reply until tomorrow.

    The code I have presently is still a little on the slow side - ie approx. 40 secs to process just 1000 keywords against the 18k+ locations
    Given this code needs to be scalable to handle in excess of 20k keyword phrases this (code/approach) simply isn't viable and requires a re-think on my part.

    The ordering of your locations is obviously important and I trust the entries are listed as they are in your sample deliberately ?
    (towns, states, countries & continents in that order)

  15. #15
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Partial matching cells with locations

    I inserted a column for results like so:
           -------------A------------- --B-- --------C--------
       1            Keywords                     Location     
       2   reed.co.uk                        central london   
       3   reed recruitment                  city             
       4   reed jobs                         east london      
       5   reed accountancy                  north london     
       6   reed employment                   north west london
       7   reeds                             south east london
       8   www.reed.co.uk                    south west london
       9   reeds recruitment                 west london      
      10   reed uk                     18014 aberdeen         
      11   reed agency                       aboyne           
      12   reeds jobs                        alford           
      13   reed.com                          ballater         
      14   reed employment agency            ellon            
      15   reed sign in                      fraserburgh      
      16   recruitment                       huntly           
      17   reed specialist recruitment       insch            
      18   reed scientific                   inverurie
    Then run this:
    Sub x()
        Dim iRow        As Long
        Dim cell        As Range
        Dim av          As Variant
        Dim v           As Variant
        Dim asWd()      As String
        Dim vsWd        As Variant
        Dim i           As Long
        
        With CreateObject("Scripting.Dictionary")
            av = Range("C2", Cells(Rows.Count, "C").End(xlUp)).Value
            iRow = Range("C2").Row
    
            For Each v In av
                If .Exists(v) Then
                    .Item(v) = .Item(v) & Format(iRow, ",0")
                Else
                    .Add Key:=v, Item:=CStr(iRow)
                End If
                iRow = iRow + 1
            Next v
            Beep
    
            av = WorksheetFunction.Transpose(Range("A2", Cells(Rows.Count, "A").End(xlUp)).Value)
    
            For i = 1 To UBound(av)
                asWd = Split(av(i))
                av(i) = vbNullString
    
                For Each vsWd In asWd
                    If .Exists(vsWd) Then
                        av(i) = av(i) & .Item(vsWd) & ","
                    End If
                Next vsWd
                If Len(av(i)) Then av(i) = Left(av(i), Len(av(i)) - 1)
            Next i
        End With
    
        With Range("B2").Resize(UBound(av))
            .NumberFormat = "@"
            .Value = WorksheetFunction.Transpose(av)
        End With
    End Sub
    Entia non sunt multiplicanda sine necessitate

  16. #16
    Registered User
    Join Date
    03-21-2011
    Location
    London,England
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Partial matching cells with locations

    Thanks for having a look.

    Actually I too tried a lot of normal excel stuff and could'nt find what I was looking for. VBA should be fine if you can please tell me where that formula goes in VBA exactly. I only know how to get to the homescreen of VBA in excel.

    Thanks again. I really appreciate your effort

  17. #17
    Registered User
    Join Date
    03-21-2011
    Location
    London,England
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Partial matching cells with locations

    One last thing SHG, will this Macro work on any number of keywords and locations or there is a limitation. This was a partial list. My complete list has 125,000 keywords and same number of locations. The keywords can have upto 9 words in them. Running this on the complete list gives a type mismatch error and doing a debug points to the following location inside the macro

    av = WorksheetFunction.Transpose(Range("A2", Cells(Rows.Count, "A").End(xlUp)).Value)

  18. #18
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Partial matching cells with locations

    I would not expect there to be a row limitation on the size of an array that can be sucked into memory, but there may certainly be a limitation of absolute array size, and the transpose operation transiently doubles the memory demand (I think; DO, Colin?).

    The code could be modified to avoid that, and could be modified to use a Location list on one sheet and multiple keyword lists on other sheets (the names of those lists seems reversed to me).

    If you want to put the full Monty on box.net and post a link I'll look at it.
    Last edited by shg; 03-23-2011 at 11:54 AM.

  19. #19
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Partial matching cells with locations

    In XL2007 it looks like TRANSPOSE() is limited to 65536 elements. It used to be 5461.
    Hope that helps,

    Colin

    RAD Excel Blog

  20. #20
    Registered User
    Join Date
    03-21-2011
    Location
    London,England
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Partial matching cells with locations

    thanks for your help last time mate.

    I am facing a very similar probleum again. Actually we added 700 new keywords to our site which in result created 35000 new pages (keyterm & keyterm + location pages). We want to have a look at all our keywords and check if how many of these 700 are driving traffic.

    So now we have a list of around 1,00,000 terms that drove traffic to our site last week and we want to find how of our 700 terms that we added can be found (even partially) in those 700.

    I tried using the above macro but unfortunaely it works only if these 700 terms are 1 word only and does'nt show any results if they have more than 1 word.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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