+ Reply to Thread
Results 1 to 8 of 8

Macro to Derive Keyword Statistics on a Word by Word Basis

  1. #1
    Registered User
    Join Date
    11-19-2012
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Excel 2010/Mac 2011
    Posts
    4

    Macro to Derive Keyword Statistics on a Word by Word Basis

    Hello! I've recently been experimenting with Excel macros as a means to quickly analyze statistics from search query reports on a word by word basis. Essentially, what I'm looking for is a way to derive the statistics for each individual word in the attached "Search Term Report" file. You'll find the raw data on the first tab. I can already do this by using text to columns, then cutting/pasting for an absurd amount of time, the result of which is the "Sorted Keywords" tab - then finally generating a pivot table at the end to identify overall trends on a word-by-word basis.

    My hope is that there's an easier way to do this process through the use of a macro. I've tried recording macros manually to copy the process used in the above spreadsheet, but it hasn't been helpful, as it's specific to the length of the report/queries/columns, that kind of thing. I think. I'm still new to this stuff.

    I've seen some word frequency count macros that are able to sort the keyword list in the fashion I'm looking for (which I've also attached), but nothing that's been able to associate the relevant data with each word yet. Thanks!

    Search Term Report.xlsx

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Macro to Derive Keyword Statistics on a Word by Word Basis

    Hi

    Make sure you have a blank sheet in the workbook called Sheet2 and try

    Please Login or Register  to view this content.
    HTH

    rylo
    Last edited by rylo; 11-19-2012 at 10:07 PM.

  3. #3
    Registered User
    Join Date
    11-19-2012
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Excel 2010/Mac 2011
    Posts
    4

    Re: Macro to Derive Keyword Statistics on a Word by Word Basis

    Man, you are a literal wizard. This is exactly what I need.

    One thing, though: I get "Run-time error '91' - Object variable or With block variable not set" coming up when I run the macro, and then it gives me the option to debug the first findit.Offset (0, 1) Value... line. I think this particular issue is cutting off the macro from running completely, as the stats are still slightly off from when I compile it manually.

    This is still a million times closer than I'd ever get on my own. Thank you!

    Edit: I should say, I get that run-time error with other, longer reports. On the original report it works perfectly!
    Last edited by monoptic; 11-20-2012 at 12:03 PM.

  4. #4
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Macro to Derive Keyword Statistics on a Word by Word Basis

    Hi

    Can you build an example file that will replicate the error? Off hand, I'd say there was some sort of special character in the data that is causing a problem, but that would only be a starting point.

    rylo

  5. #5
    Registered User
    Join Date
    11-19-2012
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Excel 2010/Mac 2011
    Posts
    4

    Re: Macro to Derive Keyword Statistics on a Word by Word Basis

    Quote Originally Posted by rylo View Post
    Hi

    Can you build an example file that will replicate the error? Off hand, I'd say there was some sort of special character in the data that is causing a problem, but that would only be a starting point.

    rylo
    Sure thing.

    I've got the Raw report attached below containing strictly data. I've also included a copy of it with the half-completed macro. I also compiled a manual version of the same report to cross reference the results, though it might be slightly off due to lagging data from when I last pulled it. Let me know if you need anything else!

    Search Term Report Raw.xlsx
    Search Term Report with Macro.xlsx
    Search Terms Manual.xlsx

  6. #6
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Macro to Derive Keyword Statistics on a Word by Word Basis

    Hi

    OK, found the problem. In cell A2499, one of the items is 04. Of course when this is pasted into Excel, it becomes 4 and converts to a number. However, the find is trying to find a string of 04, so no match so fail. What I've done is to make column A of the output sheet text, so when it copies across 04, it stays as 04.

    Please Login or Register  to view this content.
    rylo

  7. #7
    Registered User
    Join Date
    11-19-2012
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Excel 2010/Mac 2011
    Posts
    4

    Re: Macro to Derive Keyword Statistics on a Word by Word Basis

    Man, that is outstanding. It makes my dinky work laptop fry trying to run it, but my home PC can handle it just fine. You're amazing, and it works perfectly. Thanks!

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Macro to Derive Keyword Statistics on a Word by Word Basis

    @monoptic/rylo

    I hope you don't mind me jumping on the back of this thread but this query/answer is quite opportune for me as I will be doing something similar in the near future. This thread may have saved me hours of research and development of my own code. And, even if it's not quite the same, it will have given me a huge head start.

    I have taken the liberty of adding to the code and modifying it slightly. The core is unchanged but I've added some sorting, filtering and formatting which you may find useful. Oh, and I tend not to use Autofill preferring just to put the formula into the whole range from the outset.

    Enjoy:

    Please Login or Register  to view this content.


    Thanks again.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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