• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 319
  • Last Modified:

Is it possible to pass a parameter from a VBA sub to a User Form ?


I have an Excel VBA application which displays a User Form when I click in the first column of a sheet (it displays the field values of the row clicked upon, in the User Form).

The User Form allows me to update the fields and then click on an "Update" button which will update the original sheet row with the new values.

However, I'm getting compilation errors because I'm not sure how to work out which row it should be updating. If I could pass the row number as a parameter from the sheet to the User Form then that would do the trick. But I can't get that to work either.

Any ideas
  • 2
1 Solution
Martin LissOlder than dirtCommented:
Put something like

Pubikc  TheRow As Long

At the top if some module. You can then modify it and read it from anywhere.
Martin LissOlder than dirtCommented:
That should be Public.
Zack BarresseCEOCommented:
How is your UserForm displayed? You can do this by setting your userform to a variable itself and having a control (set to hidden) get this value. But I'm not sure you need to go that far really. Is it the active cell? If so, just use that range object. I'd do either of those before using a Public variable, but that works as well.

Zack Barresse
TocogroupAuthor Commented:
Hah, wondering what you were trying to say.
Many thanks for that. Works a treat.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now