How to use VBA in Excel for Google Search

+1 vote

Using VBA in Excel, I'm attempting to construct a Google Search technique. I want to enter a specific word or words in the pop-up box and have Google search those words together with a specified phrase.

Instead of having to input "License and Registration" every time I type a name, I would prefer the Google search to be "John Doe License and Registration" for instance.

How do I modify my code to include "License and Registration"?

Private Sub CommandButtonSearch_Click()
    Dim query As String
    Dim search_string As String
    Dim googleChromePath As String
    
    query = InputBox("Enter your keyword", "Google Search")
    search_string = Replace(query, " ", "+")
    
    googleChromePath = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
    
    Shell (googleChromePath & " -url http://google.com/search?q=" & search_string)

End Sub

How it looks:
enter image description here

How I would like it to look:
enter image description here

Oct 7, 2022 in Others by Kithuzzz
• 28,900 points
348 views

1 answer to this question.

0 votes

Try this:

Private Const LicenseRegistration As String = "+License+and+Registration"
Private Sub CommandButtonSearch_Click()
    Dim query As String
    Dim search_string As String
    Dim googleChromePath As String
    
    query = InputBox("Enter your keyword", "Google Search")
    search_string = Replace(query, " ", "+") & LicenseRegistration
    
    googleChromePath = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
    
    Shell (googleChromePath & " -url http://google.com/search?q=" & search_string)

End Sub
answered Oct 7, 2022 by narikkadan
• 53,520 points

Related Questions In Others

0 votes
1 answer

How to use for loop in Flutter?

Hi@akhtar, As the name suggests Dart for in ...READ MORE

answered Sep 3, 2020 in Others by MD
• 95,420 points
17,524 views
0 votes
1 answer

SEO - How to Show Phone Numbers in Google Search

<div itemscope itemtype="http://schema.org/LocalBusiness">         <span itemprop="telephone"><a href="tel:01234555666">Link Text Here</a></span>     </div> use ...READ MORE

answered Feb 14, 2022 in Others by narikkadan
• 53,520 points
93 views
0 votes
1 answer

SEO - How to Show Phone Numbers in Google Search

<div itemscope itemtype="http://schema.org/LocalBusiness"> ...READ MORE

answered Feb 22, 2022 in Others by narikkadan
• 53,520 points
344 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
532 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
2,414 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 22,960 points
117 views
0 votes
1 answer

How to use relative names in Excel VBA

It appears you are looking for Range.Offset() http://msdn.microsoft.com/en-us/library/office/ff840060%28v=office.15%29.aspx However, you ...READ MORE

answered Dec 24, 2022 in Others by narikkadan
• 53,520 points
47 views
0 votes
1 answer

How do I use the Indirect Function in Excel VBA to incorporate the equations in a VBA Macro Function

Try this: Sub Test() Dim str As String: str ...READ MORE

answered Jan 19 in Others by narikkadan
• 53,520 points
62 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP