Solved

VBA and Macro

Posted on 2013-05-12
7
385 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 46

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 46

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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

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 46

Expert Comment

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

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

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…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

856 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