Solved

VBA and Macro

Posted on 2013-05-12
7
383 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error on link 14 36
What is format f12.8 for a CSV file 6 37
InternetExplorer object in Excel VBA. 4 21
VB.NET Repostiory Pattern 7 8
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

919 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

16 Experts available now in Live!

Get 1:1 Help Now