Im looking to run multiple macros, not just one. How do I change this code to do that?
This code works but only runs one macro. I want to run multiple.
Any help here is progress. ThanksPlease Login or Register to view this content.
Im looking to run multiple macros, not just one. How do I change this code to do that?
This code works but only runs one macro. I want to run multiple.
Any help here is progress. ThanksPlease Login or Register to view this content.
Hi,
What you mean is that, when the user selects 2 check boxes you need to run 2 procedures (macros).
Basically the user can select multiple check boxes , am i clear with what you need ?
Happy Computing ,
Xlbiznes.
To show your appreciation please click *
Try this.
Please Login or Register to view this content.
If posting code please use code tags, see here.
Hi, you could try something lik this
Havent tested the code as i dont have time at the moment, but might help you start
Please Login or Register to view this content.
Please Login or Register to view this content.
Regards
Sean
Please add to my reputation if you think i helped (click on the star below the post)
Mark threads as "Solved" if you have your answer (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [code]
Please supply a workbook containing example Data: It makes its easier to answer your problem & saves time!
@ xlbiznes yes, That is what im looking for.
@ Norie, i get a "runtime error 424, Object required" that i had received before and i do believe its because of the "zlOn Then" code. not quite sure though. I have tried the If Then clause but i havent been able to get it to work.
@ Sean I get the same thing with yours also Sean,
going to keep testing and tweeking
Last edited by krackaberr; 02-25-2013 at 10:26 AM.
Hi,
You can simply loop through your existing code 15 times (Based on your code i could see 15 check boxes).
Please find the code below , basically its your code with my additional lines of code.
Please Login or Register to view this content.
krackaberr
Where do you get the error?
Please Login or Register to view this content.
@ xlbiznes is the loop going to re-run macros it has already run? seems like I need to clear the last Checkbox run before end of each loop
Last edited by krackaberr; 02-25-2013 at 10:36 AM.
"Runtime code 424 Object Required"
@ xlbiznes
Please Login or Register to view this content.
I have found that running macros with checkboxes is very picky.... i like c++.... maybe thats kinda why i get confused quickly.
You are absolutely right. I missed that completely.
Here you go.
Please Login or Register to view this content.
@ xlbiznes now im getting the same error on a different line.
Please Login or Register to view this content.
krackaberr,
this would happen , only if the check box control is not present on the sheet.
Run your initial code and see what happens.
now i do believe that any code that compares(case=comparison), is going to come back with run time errors. are there other codes that do the same statement?
Inital code works fine....
stepping into the code, it looks at the value of the check box, runs macro, then stops at that line with runtime error
Last edited by krackaberr; 02-25-2013 at 10:56 AM.
krackaberr
Can you check that there is a checkbox with the name 'Checkbox 12' on the active sheet?
Also, do any of the subs you are calling select/activate other sheets?
If they do then ActiveSheet might not be referring to the correct worksheet.
In fact why not change ActiveSheet to Worksheets("TheNameOfTheWorksheetWithTheCheckboxesOnIt")?
yes you are correct, i have to have it go to the main sheet again... adjusting code now...
xlbiznes,
it didnt seem to like the worksheets("") code, so i went with this instead... some tweeking is needed but it seems to work.
Please Login or Register to view this content.
Did you try adding an explicit worksheet reference instead of just ActiveSheet like I suggested?
Like this, which worked for me.
Please Login or Register to view this content.
Last edited by Norie; 02-25-2013 at 11:31 AM.
i tried yes, but when i debugged, it wanted an end of line instead of check box...
Have a look at the code I added and the attached file.
Last edited by Norie; 02-25-2013 at 11:50 AM.
I tried the code... assigned it, nothing happened... i mean nothing.
it seems like the case statement works. not the if then statement.
@ xlbiznes how do i add a msg box where if nothing is checked it pops up no checkbox selected, and if there was one selected it runs macro and then pops up message Macro/s Completed?
I didnt have this part of the code in the main tab code.
This does work too....
For my application, i would need to clear all the check boxes at the end of the code, looking into this now. then message boxes after that.
Please Login or Register to view this content.
Last edited by krackaberr; 02-25-2013 at 12:06 PM.
I just used that code to generate the checkboxes for testing, you can ignore it.
If you want messages try this.
Please Login or Register to view this content.
To reset the checkboxes, i used thein another sub and called that at the end of the inital sub. just to make it look clean.Please Login or Register to view this content.
Messages, i couldnt figure out how to declare variables, for my life, as the names are different from c,c++. im not multi-lingual as far as programming goes. same ideas but different words. ugh.
Thanks to the both of you for all your input. both versions do work, but the case statement i think is harder to tweek as far as adding into the code. maybe just me though
Select Case is desgined to only run the case that's true, it's not designed to run multiple cases.
PS Doesn't C++, C use int (Integer) and long (Long)?
when vb uses if then clauses, does it run the then clause until it sees else of end if or can i use nested if thens?
if that be the case can i add a statement in case of that macro not being able to point to a tab(tab does not exist) in certain cases?
yes int but long not really, it uses double more. its the same a long or floating point.
Last edited by krackaberr; 02-25-2013 at 01:07 PM.
You can use nested Ifs but I don't quite see how that would help when a sheet doesn't exist.
i would be using if statements in my macro subs...
i was thinking of this...
but im not sure yet how im going to use it yet.Please Login or Register to view this content.
thinking
On error resume next
worksheetexists = (sheets(WorksheetName).Name <> "Project Info")
if worksheetexists = true then
macro
else
next
Last edited by krackaberr; 02-25-2013 at 01:24 PM.
If this is about the subs perhaps you should start a new thread.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks