0

I have an excel sheet which has a button which when pressed shows up an userform where the user enters his credentials to login to a website from excel. Now I am trying to add another sheet with another button which does the same functionality but login to another website. That is when user presses button in first sheet he should be able to login to first website, in case the userform is initialized from second page, user should be able to login to second website. In short, is there a way for my VBA code to know from which page the userform was initialised.
In this case how can I reuse the same user form twice?

1
  • What code are you using? Commented Jun 30, 2015 at 15:29

1 Answer 1

2

Here you can find Jon Peltier's explanation on using properties within user forms: User Form Properties

Using a property to establish which page the userform was initiated from, will enable your code to be cleaner and easier to update in the future. You will have something like:

Procedure1 is assigned to button1, which when pressed assigns a value to the userform property, and then calls the userform to enter credentials. The userform property allows you to identify that the user clicked button1, and thus wants to logon to website1. Similarly, if button2 is pressed, procedure2 is run, assigning a different value to the userform property, allowing the userform to know that once the credentials have been entered, the user wishes to logon to website2.

Hope that helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.