excel - Nesting two IF statements inside a selection change, both with exit sub and call module -


i want combine these 2 codes 1:

private sub worksheet_selectionchange(byval target range)   if intersect(target, range("al1")) nothing exit sub   application.run "module2.sub1" end sub 

and

private sub worksheet_selectionchange(byval target range)       if intersect(target, range("al2")) nothing exit sub       application.run "module2.sub2" end sub 

doing cancels out second if statement, keeps working first one

private sub worksheet_selectionchange(byval target range) if intersect(target, range("al1")) nothing exit sub       application.run "module2.sub1" if intersect(target, range("al2")) nothing exit sub       application.run "module2.sub2" end sub 

i found copde snippet online, guess don't need end if because of exit sub...but need head around one. help?

i'm doing able have tool tips shapes run macros.

the problem exit sub token. when select al2 first line returns nothing , exits sub. try instead:

private sub worksheet_selectionchange(byval target range)     if not intersect(target, range("al1")) nothing application.run "module2.sub1"     if not intersect(target, range("al2")) nothing application.run "module2.sub2" end sub 

note, if select both cells both subs run.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -