|
-
Feb 11th, 2005, 05:06 PM
#1
Thread Starter
Junior Member
Calling a procedure with a Userform
I hope I explain this well.
I have 2 workbooks. One is a compilation ofdata from 4 different worksites. The other holds the monthly totals from the first book on a sheet that shows Jan thru Dec in each year, with the last several years for comparison.
2000 2001 2002 2003 2004
Jan
Feb
March (just to give you an idea)
i have the macro worked out to open the second book, and copy/paste the info to the proper site, month year (a macro for each month). What I don't have is a way to Call the proper month. I created a user form with OptionButtons, one for each month. Now it was easy enough to plug in
OptionButton1_Click()
Sub
Call January
End Sub
But it executes immediately, as soon as I click the Month (optionButton). I wanted a way to protect myself from clicking too quickly and making a mistake, so I wanted to be able to click the month, and then press ENTER to execute the Call. This way I could look things over before I make a mistake.
Should I use check boxes instead? Any suggestions would be appreciated.
If I have been unclear, please let me know and I will try to clarify.
Thanks again for your help.
Don
Edit: I use Office XP 2002. Also, I tried declaring a variable (eg myMonth),
and then
Call myMonth
but it simply will not do it. ( i obviously could have written it wrong) I keep getting the error "Expexted Sub, Function, or procedure"
Thanks
Last edited by Toolman; Feb 11th, 2005 at 05:10 PM.
Don
-
Feb 11th, 2005, 06:49 PM
#2
Re: Calling a procedure with a Userform
You should use a checkbox to replace the option button and a command button
to execute after you are sure that it is the option you really want.
HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 12th, 2005, 10:43 AM
#3
Thread Starter
Junior Member
Re: Calling a procedure with a Userform
Thanks, RobDog;
If possible, could you give a short example of the code. I'm confused as to how to implement this. Thanks,
Don
-
Feb 12th, 2005, 11:34 AM
#4
Re: Calling a procedure with a Userform
Place the code in the option button in a command button. Then add a checkbox. When you click
the command button you check the value of the checkbox and act accordingly.
VB Code:
Private Sub CommandButton1_Click()
If CheckBox1.Value = True Then
'do code that was in your optionbutton
End If
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 12th, 2005, 06:16 PM
#5
Thread Starter
Junior Member
Re: Calling a procedure with a Userform(Resolved)
Thank you so much for your help. It may seem silly but I had such a hard time working that out.
Thanks again.
Don
-
Feb 12th, 2005, 06:18 PM
#6
Re: Calling a procedure with a Userform
Dont worry about it. We all have those kind of days
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|