+ Reply to Thread
Results 1 to 15 of 15

Grouped items and identifying the group

  1. #1
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Grouped items and identifying the group

    Not sure f this can be done but knew if anyone did know....

    Two buttons in a group (called "y", "n", and "gp_test")

    Snippet of code (that I assigned to the group but has trickled down to the two buttons).

    Please Login or Register  to view this content.
    And that will give me "y" or "n", not surprisingly. Just wondering is there any way to identify the group that the button belongs to?

    The end game, to put some context on it, is to have a series of these. At present I can name them btn_1_y and btn_1_n and so on then use code to colour them accordingly. I'd like to cheat by making all buttons just y or n and use the group name to identify them (in the above case btn_1_).

  2. #2
    Valued Forum Contributor
    Join Date
    08-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2007, 2010, 2013, 2016, Office 365
    Posts
    467

    Re: Grouped items and identifying the group

    Hi Mal

    Well I'm guessing your grouped items are on a Form.
    In which case, you can use the Tag property of your buttons to 'hold' the group they belong to.

    If your group is on a worksheet, then you can use the AlternativeText property of a shape to hold data that can be accessed e.g.. put the name of the group in there.

    zeddy

  3. #3
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Re: Grouped items and identifying the group

    zzzeddy thanks for that.

    Basically there are two rectangular shapes making each pair of yes/no. The alternative text is a nice idea. Might look at that thanks. Although I was trying to save typing out the group name twice for each group (if you see what I mean). Was hoping I could use parent group or something like that but as yet no joy on it at all.

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,029

    Re: Grouped items and identifying the group

    How about
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    08-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2007, 2010, 2013, 2016, Office 365
    Posts
    467

    Re: Grouped items and identifying the group

    Hi Malc

    Well you are doing it afterwards.
    If you assigned AlternativeText to a shape, you could copy that shape and it would retain that property.

    zeddy

  6. #6
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Re: Grouped items and identifying the group

    Fluff

    If I do that I get an error that the specified value is out of range. Anything with parentgroup comes back like that.

  7. #7
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Re: Grouped items and identifying the group

    At the moment (the long way I'm hoping to do away with).
    1. Copy and paste the group
    2. change the name of the group
    3. change the name of each button ( for instance the buttons at question 1 may be q1_y and q1_n. Then each of the copies need to become q2_y q2_n
    So that's effectively 3 changes of names. Trying to only have to rename the group and leave the buttons simply as y or n. Cut som time (well it would have if it hadn't taken me soooo long to get this (not very) far!

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,029

    Re: Grouped items and identifying the group

    How did you group them?
    Put two shapes on the sheet, select them both & Right click, then Group.

  9. #9
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Re: Grouped items and identifying the group

    take it back. I decided to do some new shapes and do the same thing again. The code works fine. Big question is why did it not work with the original shapes? Answers on a postcard!

  10. #10
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Re: Grouped items and identifying the group

    Fluff that was how I did it - and again with the new test. Have ungrouped and regrouped and now it wants to work. Thanks again. Be nice if it stayed that way now!

  11. #11
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,029

    Re: Grouped items and identifying the group

    You're welcome & thanks for the feedback.

    It maybe getting confused if you have multiple buttons, all with the same name.

  12. #12
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Re: Grouped items and identifying the group

    Funny you should say that! UNgrouped the master set of buttons, copied and pasted a set. Grouped the two pairs (separately) and gave them different names. the code will not distinguish between the two sets (ie the parent name is always the same). So looks like I'll need to change the names of the buttons unless I can change the ID of the buttons programmatically (both yes's have the same ID and likewise the no's). Not sure if I can change the button ID though without changing the name (which si really back to where I started I guess)

  13. #13
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Re: Grouped items and identifying the group

    Scarp that - was dead easy once I stopped being a pillock trying to use .ID instead of name. I swear VBA will be the end of me. Thanks again.

  14. #14
    Valued Forum Contributor
    Join Date
    08-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2007, 2010, 2013, 2016, Office 365
    Posts
    467

    Re: Grouped items and identifying the group

    Hi

    Just remember that Excel allows you to have duplicate names for shapes on a worksheet i.e. if you assign a name to a shape via the Excel 'name box', then copy-and-paste that shape, each copy you make will retain the name you originally assigned.
    Can't say I find that a particularly useful 'feature'.

    And there isn't, as far as I'm aware, any way to access the 'internal shape counter' that exists i.e. when you create a new shape, you have no control over the numbers e.g. Rectangle 27 etc etc.

    Of course, you can re-set the internal shape counter when you copy shapes to a new worksheet or new workbook.

    ..it's why I use the Tag property (on Forms) and AlternativeText on worksheets to keep track of relevant info etc etc etc

    zeddy

  15. #15
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Re: Grouped items and identifying the group

    Knew about the taking the name right enough but didn't think as far as how it would affect the group. ANyway knocked up a little script to rename all the buttons as it ultimately doesn't matter what the buttons are called so long as the group names are coming through OK. Like the tip about alt text. I'll bear that one in mind. Cheers.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. keep grouped items together in a print job
    By onlysubime in forum Excel General
    Replies: 0
    Last Post: 04-28-2020, 05:57 PM
  2. [SOLVED] Sum all grouped items from each category
    By Iboughtthefarm.ca in forum Excel General
    Replies: 8
    Last Post: 08-11-2016, 03:37 PM
  3. HELP: Grouped items formula
    By chollo1988 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-05-2016, 05:00 AM
  4. % Difference From on Grouped Items
    By mo4391 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 02-09-2015, 02:36 PM
  5. Replies: 0
    Last Post: 09-04-2013, 04:33 PM
  6. [SOLVED] Group values and get max date from the grouped value
    By popoyjin in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-19-2013, 02:38 AM
  7. identifying two names abriviated and grouped
    By Don Juan in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-14-2008, 06:37 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1