+ Reply to Thread
Results 1 to 9 of 9

VBA macro for Google search

  1. #1
    Registered User
    Join Date
    03-20-2017
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    4

    VBA macro for Google search

    Hi all!

    I am trying to modify a VBA macro for Google search. I want the output in excel to be the number of results (hits on Google). I have tried to change the element within the macro to "resultStats" but I keep getting bugs when I am trying to run it. The macro was at first made to gather weblinks for Google, which works perfectly.

    So I though I only had to change the element in the script but this doesn't work.

    Underneath I have attach the excel file with script.

    Hope someone have an answer to my problem.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA macro for Google search

    There is no element called resultStats and hence for the error. You are doing a fizzy search. If you look at the first URL,
    https://www.google.co.in/search?q=Monkey&rnd=3648
    it opens Google's home page, but not a specific page within Google.

  3. #3
    Registered User
    Join Date
    03-20-2017
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    4

    Re: VBA macro for Google search

    I am not sure that I understand what you mean @AB33

    I want to open Google as https://www.google.co.in/search?q=Monkey&rnd=3648 and then copy the number of hits into excel. Does it make sense?

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: VBA macro for Google search

    Do you mean this?
    Set objH3 = html.getelementbyid("resultStats")
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  5. #5
    Registered User
    Join Date
    03-20-2017
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    4

    Re: VBA macro for Google search

    Yes, however, I have overcome this problem. Thus, I still have a problem when there is no results in a search on Google. Any ideas?

    I have attached a new file.

    /Thanks
    Attached Files Attached Files

  6. #6
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: VBA macro for Google search

    Okay refer to the attached.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    03-20-2017
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    4

    Re: VBA macro for Google search

    Very helpful

    /Thanks!

  8. #8
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: VBA macro for Google search

    You're welcome Nick!

    If that takes care of your original question, please mark your thread as Solved by selecting Thread Tools (just above your first post) --> Mark thread as solved.

  9. #9
    Registered User
    Join Date
    09-23-2018
    Location
    Egypt
    MS-Off Ver
    10
    Posts
    14

    Re: VBA macro for Google search

    Hi,

    Please can you help me to apply some changes in attached macro.
    Macro give the result as "About 36,30,00,000 results (0.46 seconds) " and I wan't to get first result.
    Attached Files Attached Files

+ 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 NEED Remake- search in google and copy link
    By kunmateo93 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-06-2014, 12:19 PM
  2. Excel macro for Google search
    By olliver in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-12-2013, 08:14 AM
  3. Create Macro to import first Google Search result
    By aolo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-29-2012, 07:54 AM
  4. Macro help - use cell contents for Google search
    By tomwsanchez in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-11-2012, 08:26 PM
  5. Excel Macro to Count Google Search Results
    By jeffreytp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-07-2012, 02:37 PM
  6. Macro to search in google
    By davidstokes in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-01-2011, 10:15 AM
  7. Excel Macro to search google
    By krombie19 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-21-2011, 08:43 PM
  8. Replies: 0
    Last Post: 11-05-2009, 04:47 AM

Tags for this Thread

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