How to Open Two Hyperlinks Side by Side from Excel Cells with VBA
Question details
The user wants to open hyperlinks located in two adjacent spreadsheet cells at the same time to view before-and-after photos side by side.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Comparing two linked images from a single spreadsheet row by opening both hyperlinks simultaneously.
- Observed behavior
- Clicking links manually opens them sequentially, making it difficult to instantly compare two linked resources side by side.
Ensure your workbook is saved as a Macro-Enabled Workbook (.xlsm) and that the Developer tab is visible on your Excel ribbon so you can access the VBA editor.
Use a VBA Macro to Open Hyperlinks in Selected Cells
Run a VBA script that iterates through your highlighted cells and automatically triggers the hyperlinks inside them simultaneously.
By default, Excel only allows you to click and open one hyperlink at a time. Using a short VBA loop, you can instruct Excel to open all hyperlinks contained within the cells you have currently highlighted. Once opened, you can use your operating system's window management tools to snap the browser windows side by side.
Press ALT + F11 on your keyboard to launch the Microsoft Visual Basic for Applications (VBA) editor.
Click 'Insert' > 'Module' from the top menu. In the blank window that appears, paste the following code: Sub OpenHyperLinks() Dim Cell As Range For Each Cell In Selection ThisWorkbook.FollowHyperlink Cell.Hyperlinks(1).Address Next Cell End Sub
Close or minimize the VBA editor to return to your worksheet. Use your mouse to highlight the two adjacent cells (e.g., P2 and Q2) containing the hyperlinks you want to open.
Press ALT + F8 to open the Macro dialog box. Select 'OpenHyperLinks' from the list and click 'Run'. Both links will open in your default browser.
Once the links open in your browser, drag the tabs apart into separate windows and use your operating system's snap feature (e.g., Windows Key + Left/Right Arrow) to view the photos side by side.

Run VBA Macros to Manage Hyperlinks in WPS Office
WPS Spreadsheet provides excellent support for VBA macros, allowing you to easily automate repetitive tasks like opening multiple hyperlinks side by side. It offers a familiar interface, making it simple to create, edit, and execute your custom scripts efficiently.
- 1. Open WPS Spreadsheet: Launch WPS Office and open your workbook containing the hyperlinks.
- 2. Access the Developer Tab: Navigate to the 'Developer' tab on the top ribbon and click on 'VBA Editor'.
- 3. Insert Your Macro: Insert a new module, paste your hyperlink-opening VBA code, and save the script.
- 4. Execute the Code: Highlight the two cells with your links, click 'Macros', select your script, and click 'Run' to open them instantly.

Frequently Asked Questions
Can I use VBA to specify which browser opens which link?
Yes, but it requires more advanced VBA code. Instead of using `ThisWorkbook.FollowHyperlink`, you must use the `Shell` function to call a specific browser's executable path (like chrome.exe or msedge.exe) and pass the hyperlink address as an argument to force different links into different browsers.
Does this macro work if my cells use the HYPERLINK formula?
No, the `Cell.Hyperlinks(1).Address` method only recognizes hyperlinks inserted via the 'Insert > Hyperlink' menu or by right-clicking a cell. If your cells use the `=HYPERLINK()` function, the VBA script will return an error. You must modify the VBA code to extract the URL from the formula string.
Why do my hyperlinks open in the same browser tab instead of side by side?
This behavior is controlled by your default web browser, not Excel or VBA. To force links to open in separate windows so you can arrange them side by side, you need to adjust your browser settings (e.g., in Chrome or Edge) to prevent links from defaulting to new tabs within the same active window.




