?
Solved

VBA and Macro

Posted on 2013-05-12
7
Medium Priority
?
389 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 49

Assisted Solution

by:Martin Liss
Martin Liss earned 1000 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 49

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
Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

 

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 1000 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 49

Expert Comment

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

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

752 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