VBA & Macro Problems

How to Create an Excel Button That Opens a VBA Pop-Up Form

Adam DavisAdam Davis Nov 10, 2026 869 views

Question details

The user wants to create a clickable button in a spreadsheet that triggers a VBA pop-up form to display detailed row information, including text fields and images.

How to Create an Excel Button That Opens a Data Pop-Up Form
Product
Spreadsheet
Device & OS
not provided
Scenario
Building a custom interactive dashboard or log where clicking a button opens a detailed, user-friendly view of a specific record rather than scrolling horizontally.
Observed behavior
The user needs to successfully design a custom UserForm and write a script to populate it with data and image paths from the active row.
Before you start

Ensure your workbook is saved as a Macro-Enabled Workbook (.xlsm) so your VBA code is preserved. Additionally, verify that the Developer tab is enabled in your ribbon to access the Visual Basic Editor.

Solution 1Recommended

Build and Assign a VBA UserForm Macro

Use the VBA Editor to design a custom UserForm and write a script to populate it with row data when a button is clicked.

A VBA UserForm allows you to create a clean, customized pop-up window. By assigning a macro to a button or shape, you can automatically read data from the active row and display it in the form without navigating away from your main dashboard.

1
Open the VBA Editor

Press Alt+F11 on your keyboard to open the Visual Basic for Applications (VBA) Editor.

2
Insert and Design a UserForm

In the top menu, click 'Insert' > 'UserForm'. Use the Toolbox to add TextBoxes (for text data like trade details), an Image control (for screenshots), and CommandButtons (like a Close button).

3
Add the VBA Data Retrieval Code

Create a new Module or double-click the form to view its code. Add a subroutine (e.g., Sub ShowTradeDetails) to capture the ActiveCell.Row. Map your cell values to the TextBox variables (e.g., .txtDate.Value = ws.Cells(selectedRow, 1).Value). Use the LoadPicture(imagePath) function to load the image into your Image control.

4
Insert a Button on the Worksheet

Go back to your spreadsheet, insert a Form Control button or a Shape. Right-click it, select 'Assign Macro', and link it to your new subroutine so the form opens when clicked.

Valid Image Paths: Ensure that the image paths referenced in your worksheet cells are completely valid and accessible on your local drive, otherwise the LoadPicture function will return an error.
Advanced Macros in WPS Spreadsheet

Easily Create VBA UserForms with WPS Office

WPS Spreadsheet offers powerful built-in support for VBA and Macros, allowing you to design customized UserForms, write scripts, and automate your workflow with the same syntax used in Microsoft Excel.

  1. 1. Open WPS Spreadsheet: Launch WPS Office and open your macro-enabled (.xlsm) file containing your dataset.
  2. 2. Access the Developer Tab: Go to the 'Developer' tab on the ribbon and click 'VBA Editor' to launch the coding environment.
  3. 3. Design Your Form: Insert a new UserForm, drag and drop text fields or image controls, and paste your VBA script to load the active row data.
  4. 4. Assign Macro to Button: Insert a button shape directly on your sheet, right-click, choose 'Assign Macro', and select your UserForm trigger.
Full compatibility with Microsoft Excel VBA code and UserFormsDedicated VBA Editor for designing custom pop-up formsLightweight application that runs macros quickly and smoothlyCross-platform support for seamless workflow transitions
microsoft office alternative - wps office

Frequently Asked Questions

Can I trigger the UserForm without clicking a button?

Yes, you can use the Worksheet_BeforeDoubleClick event in VBA. By adding code to the specific sheet module, double-clicking any cell in a row can automatically launch the UserForm populated with that row's data.

Why is my image not loading in the VBA UserForm?

This usually happens if the file path in your spreadsheet cell is incorrect or if the image format is unsupported. Ensure the cell contains the full absolute path (e.g., C:\Images\chart.jpg) and check that the file exists before passing it to the LoadPicture function.

How do I add a Close button to my UserForm?

Add a CommandButton to your UserForm in the VBA Editor. Double-click the button and enter 'Unload Me' in the click event code block. This will close the pop-up form and return you to the worksheet when clicked.

Do macros work the same way in WPS Office as in Excel?

Yes, WPS Office supports standard VBA code, including UserForms, ActiveX controls, and macro assignments. Most Excel macro scripts will run seamlessly in WPS Spreadsheet without modification.