Solved

VBA and Macro

Posted on 2013-05-12
7
387 Views
Last Modified: 2013-05-13
Hi,

I am very new to excel VBA and Macro, I want to create a macro which loads the userform when we open the excel to accept inputs from the user. Can anyone please help me in getting this done with the excel.

Thanks in advance
Rajeeva
0
Comment
Question by:rajeeva_nagaraj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 48

Assisted Solution

by:Martin Liss
Martin Liss earned 250 total points
ID: 39159458
Private Sub Workbook_Open()

UserForm1.Show

End Sub

Open in new window


Do you want the "accept inputs" part to be done by the userform or my the workbook?
0
 

Author Comment

by:rajeeva_nagaraj
ID: 39159483
In userform itself
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 39159505
Okay, most often when the user is shown a Userform he just fills in textbox values or selects entries in a listbox, etcetera, but if you want to ask a question you can do it this way in the userform's code.

Private Sub UserForm_Activate()
Dim strName As String

strName = InputBox("Please enter your name", "Enter Name", "John Doe")
End Sub

Open in new window


That code will be executed when the userform's Activate event is fired. That happens when you show the form. You can put code like that in any of the userform's events. I don't know what you know about events but here's how you can see what they are.
Events
0
Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

 

Author Comment

by:rajeeva_nagaraj
ID: 39161032
Hi,

I have created the user form. If i try to save the same i am getting the message attached. Please find the message attached. Please help me in finding the way out of this issue. I have seen some excel sheets where on open it will pop up a message to enable the macro and if enabled then it will load the form. How can i do that in excel VBA. Please its bit urgent.

Regards
Rajeeva
message.bmp
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 250 total points
ID: 39161073
No points for this.....

You should save the file with the .xlsm extension and not with the regular .xlsx extension.


When you get that message,
Click no
from the file type box select Macro enabled
Save the file
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 39161309
rajeeva_nagaraj

As I had clearly mentioned my comment was for "No points". Your problem was completely solved by MartinLiss.
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 39161417
I don't mind sharing.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

689 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question