Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Execute code when grouping buttons used

I was hoping to find a Worksheet command that could identify when a row
grouping was expanded or collapsed by user, then execute some additional code
immediately following the completion of that action. I thought it might work
with either Worksheet_Change or Worksheet_Calculation, but neither of these
seem to work. Any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Execute code when grouping buttons used

I was hoping to find a Worksheet command that could identify when a row
grouping was expanded or collapsed by user, then execute some additional
code
immediately following the completion of that action. I thought it might
work
with either Worksheet_Change or Worksheet_Calculation, but neither of
these
seem to work. Any ideas?



Hi

I found a workaround for this. When you group/ungroup, the relevant rows are
hidden/unhidden. Unfortunately, hiding and unhiding rows doesn't in itself
fire up the Worksheet_Change or Worksheet_Calculation event. But you can get
around this by using the =SUBTOTAL function, with a first argument of 103,
which is COUNTA, ignoring hidden cells (Excel 2003 and later).

Say your grouped rows are Rows 3 to 5 inclusive, enter a 1 in a cell in each
of those rows in a column way over to the right of your data, say col X - so
put 1 in each cell in X3:X5. Then enter =SUBTOTAL(103,X3:X5) in say cell X1.
As the rows are hidden (grouped) / unhidden (ungrouped) cell X1 will return
0 or 3. This will trigger the Worksheet_Calculation event, that you can use
to fire up your code.

Hope this helps.

Ian

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Execute code when grouping buttons used

That works! Thank you so much for that creative approach!

"IanKR" wrote:

I was hoping to find a Worksheet command that could identify when a row
grouping was expanded or collapsed by user, then execute some additional
code
immediately following the completion of that action. I thought it might
work
with either Worksheet_Change or Worksheet_Calculation, but neither of
these
seem to work. Any ideas?



Hi

I found a workaround for this. When you group/ungroup, the relevant rows are
hidden/unhidden. Unfortunately, hiding and unhiding rows doesn't in itself
fire up the Worksheet_Change or Worksheet_Calculation event. But you can get
around this by using the =SUBTOTAL function, with a first argument of 103,
which is COUNTA, ignoring hidden cells (Excel 2003 and later).

Say your grouped rows are Rows 3 to 5 inclusive, enter a 1 in a cell in each
of those rows in a column way over to the right of your data, say col X - so
put 1 in each cell in X3:X5. Then enter =SUBTOTAL(103,X3:X5) in say cell X1.
As the rows are hidden (grouped) / unhidden (ungrouped) cell X1 will return
0 or 3. This will trigger the Worksheet_Calculation event, that you can use
to fire up your code.

Hope this helps.

Ian


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Execute code when grouping buttons used

That works! Thank you so much for that creative approach!

You're very welcome. I've always found the Worksheet_Change event a bit of a
disappointment, in that it doesn't always fire when you'd expect (you would
have thought that hiding/unhiding rows or columns would constitute a
"change", but apparently not, according to MS!). So I often have to think up
workarounds like this. They keep you on your toes, so to speak.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Grouping Option Buttons [email protected] Excel Programming 11 September 20th 06 02:57 AM
How do I execute buttons in Excel using a voice command? Rick Drabek Excel Discussion (Misc queries) 0 November 11th 05 10:01 PM
grouping of option buttons mapi62 Excel Discussion (Misc queries) 0 February 22nd 05 12:19 PM
Creating command buttons beside every row to execute each row macro sirriff Excel Programming 3 September 12th 04 03:42 AM
Grouping Option Buttons m@_ Excel Programming 3 November 5th 03 02:20 AM


All times are GMT +1. The time now is 08:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"