Home » excel » excel – Getting the activecontrol name and value from a multipages form

excel – Getting the activecontrol name and value from a multipages form

Posted by: admin April 23, 2020 Leave a comment

Questions:

I’ve been searching the web for a solution for a couple of months without any success.
I created in Excel 2010 a UserForm with multipages. I’m trying to write a function that will get the activecontrol name and value.

Until now, I succeeded in getting the name of the control using this command
Me.MultiPage1.Pages(Me.MultiPage1.Value).ActiveControl.Name but the only thing I managed to do with it was to set it in to a variable as a string.
I still need to get it’s value.

I really appreciate any help.
blackmail

How to&Answers:

You can access the value of the last active control in the MultiPage control with this code:

Me.MultiPage1(Me.MultiPage1.Value).ActiveControl.Value

However, I’m not sure that every kind of control has a .Value property, so make sure that all your different controls in the Multipage has one – or include a proper error handler!