Excel VBA Tutorial 55 - How to Google Search Using Excel VBA

Share
Embed
  • Published on Feb 9, 2015
  • Excel VBA Tutorial Series - How to Google Search Using Excel VBA

Comments • 14

  • Best Funny Videos

    May I get these code

  • Dovydas Jankauskas

    438 Run time error ?

  • the_feature_selector

    didnt work

  • Indian Mechanic
    Indian Mechanic 2 years ago +1

    Nice tutorial and video. Subbed!

  • Ferral JC
    Ferral JC 2 years ago

    Hi Jay3sh
    I'm working in Office 2016. Although your code is nice, I am unable to have the google website search what I put as my cell value. The google search bar on google.com will display what I typed into my cell in excel but it will not search until I click the Google Search button online to see my results. This is the code I used from your video:
    Sub GoogleSearch()
    Dim MyItem As String, MyIe As Object, MyLoop As Object, MyElements As Object
    MyItem = Range("B2").Value
    Set MyIe = CreateObject("InternetExplorer.Application")
    MyIe.navigate "www.google.com"
    While MyIe.busy = True
    Wend
    Set MyElements = MyIe.Document.GetElementsbyTagName("Input")
    For Each MyLoop In MyElements
    If MyLoop.Name = "q" Then: MyLoop.Value = MyItem
    If MyLoop.Value = "Google Search" Then: MyLoop.Click: Exit For
    Next MyLoop
    MyIe.Visible = True
    End Sub

    Perhaps the Google we have now in 2017 too updated. Any advice?

    • Jayesh Madnani
      Jayesh Madnani  2 years ago

      +JC Ferral Thank you mate. glad it works!

    • Ferral JC
      Ferral JC 2 years ago

      I must say your skills are very impressive. The code works like a charm. Your videos are very educational. Thank you for taking the time and effort to post.

    • Jayesh Madnani
      Jayesh Madnani  2 years ago

      Gotta admit i've lost touch..Took me a good 5 minutes to figure out the solution.
      Try this please..
      Sub GoogleSearch()
      Dim MyItem As String, MyIe As Object, MyLoop As Object, MyElements As Object
      MyItem = Range("B2").Value
      Set MyIe = CreateObject("InternetExplorer.Application")
      MyIe.navigate "www.google.com"
      While MyIe.busy = True
      Wend
      MyIe.Visible = True

      Set MyElements = MyIe.document.getElementsbyTagName("Input")
      For Each MyLoop In MyElements
      If MyLoop.Name = "q" Then: MyLoop.Value = MyItem
      If MyLoop.Value = "Google Search" Then
      MyLoop.Focus
      MyLoop.Click
      MyLoop.fireevent ("onsubmit")
      End If
      Next MyLoop
      MyIe.document.getelementbyid("_fZl").Click
      MyIe.document.getelementbyid("lst-ib").Value = MyItem

      MyIe.Visible = True
      End Sub

  • Scott Mathison
    Scott Mathison 3 years ago

    When I run this it says this object doesn't support this property or method, but doesn't show me what object it has the problem with.