Forum Discussion
Can you create a Button that Opens a Pop-Up with Data from Spreadsheets
Good evening,
I have moderate knowledge of excel, and some knowledge of visual basic and am trying to develop a personal trading journal log. My intent is to create a pop-up for trades that I can input a lot of detailed data and an image of the trade that will then auto-populate a brief information row for a quick glance, but will also have a button in the row that populates for each trade that, if clicked, will open a pup-up of all the information given including the picture, comments about the trade in reflection and review, etc. I have been searching for if this is possible and haven't really found any information on it, only things like pop-ups for inputting data. Can anyone help me determine if this is possible, and if so how? Thank you.
2 Replies
Take this:
Step 1: Design the UserForm
- Press Alt + F11 to open the VBA Editor.
- Go to Insert > UserForm.
- Add controls like:
- TextBoxes for trade details (e.g., entry price, exit price, strategy).
- Image control to display a screenshot or chart.
- CommandButtons for actions like "Close" or "Edit".
Step 2: Populate the Form Dynamically
In your worksheet, each row could have a button (or you could use a double-click event). When clicked, it should:
- Read the data from that row.
- Load the data into the UserForm controls.
- Show the form.
Sub ShowTradeDetails() Dim ws As Worksheet Set ws = ThisWorkbook.Sheets("Trades") Dim selectedRow As Long selectedRow = ActiveCell.Row With TradeForm .txtDate.Value = ws.Cells(selectedRow, 1).Value .txtSymbol.Value = ws.Cells(selectedRow, 2).Value .txtEntry.Value = ws.Cells(selectedRow, 3).Value .txtExit.Value = ws.Cells(selectedRow, 4).Value .txtComments.Value = ws.Cells(selectedRow, 5).Value ' Load image Dim imgPath As String imgPath = ws.Cells(selectedRow, 6).Value ' Assuming column 6 has image path If Dir(imgPath) <> "" Then .imgTrade.Picture = LoadPicture(imgPath) Else MsgBox "Image not found." End If .Show End With End SubStep 3: Add a Button to Each Row
You can insert a Form Control Button or use a shape and assign the ShowTradeDetails macro to it. Alternatively, use a double-click event on the row.
- Brksy86Copper Contributor
Thank you, I think this is putting me on the right track. One additional question to see if this is what I was thinking.
Would the brief row in the log have to display all the information then, or would I be able to have hidden information there?
My intent is to be able to go to this worksheet and see all the trades and basics like total gain, percent gain, win/loss, and a few more to keep it small and brief and only sections like the enter/exits, total time of trade, screenshot of the trade, my comments added on what I think I did correct/wrong, or other non-data information only be seen if I used this ability to open a screen and populate the details