Ad

VBA code to open 100 website from excel sheet in Google chrome

Open Multiple Websites with Single Click in Excel Sheet

Imagine you have a list of website addresses (URLs) in an Excel sheet, and you want to open all of them one by one in Google Chrome. You can do this automatically using a special tool called VBA (Visual Basic for Applications) inside Excel. It's like giving Excel a set of instructions to follow.

The provided code is like a set of instructions written in VBA language. It tells Excel to:

1. Get the path where Google Chrome is installed on your computer.

2. Open a new instance of Google Chrome.

3. Go through the list of websites (i.e 100 URLs) listed in the Excel sheet.

4. For each URL, tell Google Chrome to open it.

5. Once all websites are opened, show a message saying it's done.

So, when you run this code in Excel, it will automatically open each website from your list in Google Chrome without you having to do it manually.

Below is a sample VBA code that opens multiple websites in a column i.e 100 websites listed in an Excel sheet in Google Chrome:

Sub OpenWebsitesInChrome() Dim chromePath As String Dim chrome As Object Dim i As Integer Dim ws As Worksheet ' Set the path to your Chrome executable chromePath = "C:\Program Files\Google\Chrome\Application\chrome.exe" ' Set your worksheet Set ws = ThisWorkbook.Sheets("Sheet1") ' Change "Sheet1" to your sheet name ' Create a new instance of Chrome Set chrome = CreateObject("Shell.Application") ' Loop through the URLs in the specified range For i = 1 To 100 ' Adjust the range according to your data If ws.Cells(i, 1).Value <> "" Then ' Open each URL in Chrome chrome.ShellExecute ws.Cells(i, 1).Value, "", "", "", 1 Else MsgBox "No URL found in cell " & ws.Cells(i, 1).Address & ". Skipping..." End If Next i ' Release the Chrome object Set chrome = Nothing MsgBox "Websites opened successfully in Google Chrome." End Sub
Make sure to replace `"C:\Program Files\Google\Chrome\Application\chrome.exe"` with the path to your Google Chrome executable. Also, adjust the sheet name and range where your URLs are located (`Sheet1` and `Cells(i, 1)` respectively). This code is for 100 websites so adjust for the number of websites you have in your list otherwise, it will give an error message until the last target in the code. To run this code, open the Visual Basic for Applications editor in Excel (Alt + F11), insert a new module (Alt + I + M), paste the code into the module window, Save and then close the editor.

Open the sheet where your URLs are listed. Click on Insert Tab, Choose the Shap Button, pick a shape and draw on the sheet where you want.
Write a text on the button and assign the micro `OpenWebsitesInChrome` to the shape. Now when you click the button this will open each website listed in the specified range in Google Chrome.

Post a Comment

0 Comments