Avatar of Tocogroup
TocogroupFlag for United Kingdom of Great Britain and Northern Ireland asked on

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
Microsoft Excel

Avatar of undefined
Last Comment
Tocogroup

8/22/2022 - Mon
Martin Liss

Put something like

Pubikc  TheRow As Long

At the top if some module. You can then modify it and read it from anywhere.
ASKER CERTIFIED SOLUTION
Martin Liss

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Zack Barresse

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
ASKER
Tocogroup

Hah, wondering what you were trying to say.
Many thanks for that. Works a treat.
Toco
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck