The attached macro counts hole wizard holes and returns the count in an excel file. How do I have it return the count in a dialog box? I assume this is possible?
If you don't need to be able to cut and paste from the dialog box it is pretty easy:
In the Main procedure, comment out the lines at the end by adding a single quote at the front and add the line shown at the end:
Comment out the entire OutputResultsToCsv function like this:
Add a new subroutine named OutputResultsToDialog. You can cut and paste a lot of it from OutputResultsToCsv :
Results look like this:
If you want to be able to cut/paste the data, you'll need to make a new UserForm with a textbox and button and wire up some events. It looks like this:
I've attached the altered macro. If you want the first option (no cut/paste), uncomment the line below (in green) in the OutputResultsToDialog subroutine and comment out the 4 lines after it:
Thanks so much, and thanks for posting how you modified it. I can run the macro from VBA but if I hit the "run macro? button on the SW toolbar nothing happens. What am I missing?
Grant Baugh wrote: Thanks so much, and thanks for posting how you modified it. I can run the macro from VBA but if I hit the "run macro? button on the SW toolbar nothing happens. What am I missing?
Grant Baugh wrote:
Are you not getting browse window to select macro file when you click on run macro?
Sorry, yes I am able to browse for the macro. Then nothing happens; the dialog box doesn't come up. It runs fine if I execute the macro through VBA.
If there is more than one sub, VBA does a crappy job of picking which one to run when you do tools->Macro->Run. I believe it runs the last one in the module that has no arguments. If you map the macro to a toolbar button you have the ability to specify which module and sub to start with.
I like to give all my subs an argument, even if it's not necessary for function. So like:
'This is where I want to start
Call aDifferentSub 'You don't actually have to include the optional argument
sub aDifferentSub(Optional DummyArgument as long)
'The dummy argument in the declaration prevents VBA from starting with this sub.
Ok. That worked. Just had to add the macro to a toolbar button. Thanks for your help everyone.
Retrieving data ...