Thread: Button Help
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Button Help


"David Balkema" wrote in message
...

If I have multiple sections, each as a different category, how do I
program it to check cells, G7, G11, G24, etc. when there will always be
new sections added. How do I make the code more dynamic. I thought
about naming a range DetSum, which will include all the cells that would
change the result to either hide or show the detail lines. Then have
that range checked to see if the Target.Address is in that named range,
and if it is execute the code.


I think that is the way that I would do it. To check if the target is in
that range, you would use

If Not Intersect (Targt,Range("DetSum")) Is Nothing Then

rather than

If Target.Address = "$H$1" Then

I'm not sure on how to dymanically change the named range and also refer
to that named range in a Union statement. I know these must be basic
questions, but I'm still learning. Thanks so much.


Defining the range dynamically is the difficult bit. If it is just an
extending contiguous range, that is easy,, but your cells seem to be
scattered, so you have a problem. I am not sure why you feel you need to use
that named range in a Union statement, but it seems to me that you would
need to manually update the range name.

Bob