Forum Discussion
Can you create a Button that Opens a Pop-Up with Data from Spreadsheets
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 Sub
Step 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.
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