Solved

VBA and Macro

Posted on 2013-05-12
7
382 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
  • 3
  • 2
  • 2
7 Comments
 
LVL 45

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 45

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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 45

Expert Comment

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

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

746 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now