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

Hi,

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
Toco
TocogroupAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
0
Martin LissOlder than dirtCommented:
That should be Public.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.

Regards,
Zack Barresse
0
TocogroupAuthor Commented:
Hah, wondering what you were trying to say.
Many thanks for that. Works a treat.
Toco
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.