VBA code to open a website in your default web browser


 Sub OpenWebsite()

    Dim URL As String

    URL = "https://www.example.com" 'Replace with your desired website URL

    Shell "explorer.exe " & URL, vbNormalFocus

End Sub

This code uses the Shell function to launch the default web browser and open the specified URL. You can customize the URL variable to open any website you want.

To execute this code, open the Microsoft Visual Basic for Applications (VBA) editor in Excel or another Office application, create a new module, and paste the code into the module. Then, you can run the OpenWebsite sub by clicking on the "Run" button in the VBA editor, or by assigning the sub to a button or hotkey in your Excel workbook.

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.