How to reopen a UserForm in File A with the selected row after navigating to File B?

mohan 0 Reputation points
2026-02-03T09:24:40.06+00:00

In file A (.xlsm), there are multiple rows. When I select a row and click a button, a popup form (.frm) opens. From this popup, I click another button that opens file B (.xlsm). After clicking a button in B (.xlsm), it should return me to file A (.xlsm) and display the previously selected row again in the popup form.

Is this even possible? I know that one macro-enabled file can open another, but is it possible to reopen the original file and show the last selected row again in a popup form?

Developer technologies | Visual Basic for Applications
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Surya Amrutha Vaishnavi Lanka (INFOSYS LIMITED) 1,725 Reputation points Microsoft External Staff
    2026-02-04T12:00:18.88+00:00

    Thanks for reaching out!

    Here are some steps below

    1. Store the Selected Row: Before you open File B, save the selected row index or the data from that row to a variable or a global variable. You can do this in the button click event that triggers the UserForm.
         Dim selectedRow As Long
      
      Assuming selectedRow will be assigned the row number of the selected row selectedRow = ActiveCell.Row
    2. Open File B: After storing the selected row, you can open File B. You might want to use Workbooks.Open to do this. Workbooks.Open "Path\to\FileB.xlsm"
    3. Return to File A: When you're done with File B, make sure to return to File A using Workbooks("FileA.xlsm").Activate.
    4. Repopulate the UserForm: Use the stored row index to select the corresponding data and load it into the UserForm as needed when reopening it.
    5. Show the UserForm Again: Finally, use the .Show method to display the UserForm again as needed.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.