I am using Excel 2010. I have created a macro through Visual Basic. I couldn't see the macro name in the list when I clicked Macros. Why? I need to type in the name in the dialogue box to run the macro. Please help. Thanks
I am using Excel 2010. I have created a macro through Visual Basic. I couldn't see the macro name in the list when I clicked Macros. Why? I need to type in the name in the dialogue box to run the macro. Please help. Thanks
Hi tywlam and welcome to the forum,
Is the Macro behind a Worksheet and Private or is it in a Module and Public?
That might be the problem.
One test is worth a thousand opinions.
Click the * Add Reputation below to say thanks.
Thanks for your reply. It is in a Module. I am learning wrirting simple VBA from an On-line tutorial which shows that Excel 2007 can show the name on the list but my Excel 2010 can't!
In Excel 2010 I just created a Sub named BOB.
Click on Macros and it shows it.
Can you attach you file? It should show in 2010 without a problem.
Do you have an End Sub at the end?
Have you compiled it?
Do you have code running that is keeping you from starting another macro? That is are you in break mode?
In the Macro Dialog near the bottom it askes for "Macros in:" Is the macro in an open workbook?
I have "End Function" instead. See below. The macro is in an open workbook. I don't know how to attach the Excel file.
Function SimpleCoinToss1()
CountHeads = 0
For i = 1 To 10
SingleToss = Round(Rnd(), 0)
CountHeads = CountHeads + SingleToss
Next i
Result = MsgBox("You got " & CountHeads & " Heads.", vbOKOnly)
End Function
Hi,
Functions aren't Subroutines. A function will not be listed in the Macro List.
Change the word Function to Sub and see if that does it.
To attach a file - click on Go Advanced and then on the Paper Clip Icon above the message area.
It doesn't even if I change to Sub!
See attached.
Pls check out below. It shows it works in Excel 2007.
http://excelmontecarlo.com/19a_run_m...worksheet.html
have tried MarvinP it works for me...
do we have the save prog.?Please Login or Register to view this content.
by the way if you insist in using functions you can call (run) with by typing in any cell =SimpleCoinToss1() -hit enter
HTH
I think people forget the word "THANK YOU!!!!" Do you still know it???
There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "
Regards,
Vladimir
It doesn't work for me and displays error message as attached.
should be
Sub SimpleCoinToss1()
not
Function SimpleCoinToss1()
Last edited by vlady; 10-26-2011 at 03:25 AM.
Thanks MarvinP and vlady. It works if using Sub
But I just wonder why the Function works in Excel2003 but not Excel2010!
Are you sure it works in xl2003?
As far as I am aware only subs with no compulsary arguments will appear in the Macro dialog.
Functions have never appeared in the macros dialog (other than perhaps XLM).
Remember what the dormouse said
Feed your head
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks