Excel Macro code to VBA Code to Search on Google

How to VBA Code to Search on Google in excel sheet through VBA Macro Code

For using this VBA macro code in excel to VBA Code to Search on Google you will have copy below Macro code in Excel Visual Basic Editor
Sub SearchWindow32()
Dim chromePath As String
Dim search_string As String
Dim query As String
query = InputBox("Enter here your search here", "Google Search")
search_string = query
search_string = Replace(search_string, " ", "+")
'Uncomment the following line for Windows 64 versions and comment out Windows 32 versions'
'chromePath = "C:Program FilesGoogleChromeApplicationchrome.exe"
'Uncomment the following line for Windows 32 versions and comment out Windows 64 versions
'chromePath = "C:Program Files (x86)GoogleChromeApplicationchrome.exe"
Shell (chromePath & " -url http://google.com/#q=" & search_string)
End Sub

Follow this post to learn how to use this VBA code to search on Google.

below code also takes the shell command out, and will open your default browser with the value you entered in your search string.

Sub GoogleSearch()

Dim MyURL As String
Dim search_string As String
Dim query As String

query = InputBox(“Enter here your search here”, “Google Search”)
search_string = query
search_string = Replace(search_string, ” “, “+”)
MyURL = “https:/google.com/#q=”

ActiveWorkbook.FollowHyperlink Address:=MyURL & search_string
End Sub

How to Search on Google using a VBA Code

Now, close VB editor and run this macro from macros option in developer tab.

How it works

When you run this code it shows you an input box to enter your query. And you need to enter your query in that input box and click OK.

Once you click OK, this code creates a search URL syntax using the text you have entered.

And, in the end redirects Chrome to that URL to give you result for query you have entered.

What is a Macro Code?

In MS Excel, macro code is a programming code which is written in VBA (Visual Basic for Applications) language.

The idea is to use macro code for automating various activities which you perform manually in Excel, otherwise.

For example, you can use a code to print only a particular range of cells just with a single click instead of selecting the range -> File Tab -> Print -> Print Select -> OK Button.

How to use a Macro Code in Excel


  • On the left side in “Project Window”, right click on the name of your workbook and insert a new module.



  • Just paste your code into the module and close it.



  • Now, go to your developer tab and click on the macro button.


  • It will show you a window with a list of the macros you have in your file from where you can run a macro from that list.





Monthly Business Budget

A monthly business budget provides a precise image of expenses and revenues and gave drive to important business decisions. Whether …

Download Now

Cash Flow Forecast

A cash flow forecast or cash flow projection is like a budget, but rather than computing revenues and expenses, it …

Download Now

Income Statement

Download Income Statement Excel Template to monitor your incomes sources The income statement displays information on the economical results of …

Download Now

Small Business Profit and loss Statement

Download Best Profit and Loss Statement in Excel for small business A profit and loss statement for small business —also …

Download Now

Yearly Profit and Loss Statement

The short term prediction is not a necessary part of a basic business plan. So, the yearly Profit and Loss …

Download Now

Profit and Loss Projection

A profit and loss, or P&L, is a projection of how much money you make by selling services or how …

Download Now