+ Reply to Thread
Results 1 to 18 of 18

Make a group of cells open upon click?

  1. #1
    Registered User
    Join Date
    04-13-2010
    Location
    Panama, Panama
    MS-Off Ver
    Excel 2007
    Posts
    30

    Question Make a group of cells open upon click?

    I'm trying to make a form to input values from a number of different sources. I would like the format to appear to users as a master list of sources (i.e. School #1, School #2, School #3...), and then when they go to input the information, they can click on the info they want to input (ie School #2), automatically opening up the cells below so they can input the info, and then close it up when done.

    I know this can be done by grouping the cells (and then users can click/unclick the + sign), but I'd really rather it just be done by clicking on the cell itself.

    The other option I've tried is having the input areas below the master list and then having each cell hyperlink to the input areas, but for formatting elsewhere in the document, it would be easier just to have the data below the master name.

    Any ideas?
    Last edited by smalls; 05-26-2010 at 03:48 PM.

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: How can I make make a group of cells open upon click?

    Hi, Try this as an Example:-
    Write in "A1" :- School1, in "A11 :- School2, and in "A21":- School3.
    Now Name the ranges in between each Name i.e Range ("A2: A10") = Name :- School1,
    Repeat for other 2 Ranges i.e Range("A12:A20") = Name:- "School2 and Range"A22: A30") =Name :- School3.
    To enter code in VB Editer, Right Click sheet Tab, Select "View Code", VB Windowe appears. Paste code below into VbWindow.
    Close Vb Window.
    To run code, Click anyone of the 3 cells with the School Names, On selection the other 2 Range/Rows should be Hidden. Repeat for other "Schools"
    Please Login or Register  to view this content.
    Regards Mick

  3. #3
    Registered User
    Join Date
    04-13-2010
    Location
    Panama, Panama
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: How can I make make a group of cells open upon click?

    Great, thanks for the help, Mick. Just two things. When I do this and click one of the cells, all of the ranges open up (Example, I click A11 and A2:A10, A12:A20, AND A22:A30 open up. I want each cell clicked on to only open the range directly below it...is there a way to edit this code to do that?

    Also, is there an easy way to make it close back up afterwards?

    Thanks again, we're definitely on the right track with this!

    smalls

  4. #4
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: How can I make make a group of cells open upon click?

    Hi, Not quite sure what's happening there !!. Before you run the code all rows should be showing.
    Then for example, when you click "School2", First of all all the Ranges show. Then ranges for School1 and School3 will be Hidden,But the row name for "School1" (in A1) will be seen above the Range which is Visible (School2) and the the row name for "School3" will be seen at the Bottom of the Visible Range (School2).
    Is this not Happenng???
    Mick

  5. #5
    Registered User
    Join Date
    04-13-2010
    Location
    Panama, Panama
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: How can I make make a group of cells open upon click?

    OK...got it to work! I think I'd been naming the ranges wrong (using the little box in the upper left). When I clicked on "define name" and did it that way, it worked.

    Is there a way to make it close back up again when clicking on the cell when the range below is open?

    Thanks again Mick!

    smalls

  6. #6
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Make a group of cells open upon click?

    Hi, Have a look at the attached File, If you want any mods , call back.
    To view the Sheet codes inthe file , Right click sheet tab, Click "View Code" or just Click "Alt +F11".
    I've added some extra code, So that if you Double click "B1" all the ranges are Visible, Double Click again, All ranges are Hidden.
    Regards Mick
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    04-13-2010
    Location
    Panama, Panama
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Make a group of cells open upon click?

    Thank you Mick!

  8. #8
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Make a group of cells open upon click?

    Hi, Have a look at the Second Sheet of the Attached File, I think that's what you want !!!
    Regards Mick
    Attached Files Attached Files

  9. #9
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Make a group of cells open upon click?

    Your attachment is giving me problems.

    In the VBEditor the Project window shows some sheets in blue.
    Also, when I write a sub that refers to ThisWorkbook, it gives me an Automation Error.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  10. #10
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Make a group of cells open upon click?

    Hi Mike, I've just Downloaded my posted file "School_1.xls" that I sent previously and it works as I sent it and as you would expect it to, I also ran the code "Msgbox Thisworkbook.name" without any problems ,so what do you think could be causing the problem.
    What happens if you down load the Original File I posted "School.xls". The second file is exacly the same but with an added sheet that's almost identical.
    I wonder if "smalls" if having the same problem ???
    Regards Mick

  11. #11
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Make a group of cells open upon click?

    I'm using Excel 2004 and the problem is with both Schools and Schools_1

  12. #12
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Make a group of cells open upon click?

    If it is of any help,
    I have opened and ran successfully both files, in both Excel 2003 and 2007.

  13. #13
    Registered User
    Join Date
    04-13-2010
    Location
    Panama, Panama
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Make a group of cells open upon click?

    Mick,

    Thanks again--just saw that you'd put exactly what I was asking for in Sheet2 of the attachment...somehow in all the back and forth I missed your response.

    Cheers,
    smalls
    Last edited by smalls; 05-31-2010 at 02:21 PM.

  14. #14
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Make a group of cells open upon click?

    Hi, If you actually want it in a "Double Click Event" then Here'sthe Code:-
    Please Login or Register  to view this content.
    Regards Mick

  15. #15
    Registered User
    Join Date
    04-13-2010
    Location
    Panama, Panama
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Make a group of cells open upon click?

    Hi Mick,

    Thanks again for your response. This is my first time writing a code in Visual Basic...can you just clarify which are the parts of your code which I will need to change in order to customize it to my sheet? I haven't been able to make it work for my particular spreadsheet, and I'm sure there's some piece of the programming which I should replace and am not.

    Thank you very much for all your help on this--if I can get it to work it will make this tool really great!

    Cheers,
    smalls

  16. #16
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Make a group of cells open upon click?

    Hi, Please see line numbers in code for relating to remarks.
    Line (1) :- shows the individual; addresses of a some cells, These are the cells with the "Names" of the "Named Ranges " that you want to hide, You can add or delete to these address for as many named ranges that you want to perform this action on.
    NB:- The Names in these Various cells must Have exactly the same name as the range of cells they refer to.:- i.e "School1" ( no Inv/commas) must be spelt exactly the same as the Range Named :- "School1".
    Line (2) Refers to the Range(Target). The target is the cell you select. If that cell is one of the cell addresess in the code line above then, Then by selecting that cell, you are carrying out an action relating to the Named range that the target cell refers to. So the range referred to in line (2) has been given the property "Hidden", and the code will try to hide this range. If the range is already hidden it will unhide it.
    Line (3) is just there, to ensure you explicitly select the require cell each time you want the code to run, so it automatically selects the cell next to the Target after the code has run.
    In order to run the code you will have to place it a worksheet event by Right clickoing the sheet Tab, Select "View code" (Vb Window Appears) and pasting it into the Vb Window.
    Please Login or Register  to view this content.
    Hope you get it working
    Regards Mick

  17. #17
    Registered User
    Join Date
    01-13-2021
    Location
    Maharashtra, India
    MS-Off Ver
    2007
    Posts
    1

    Re: Make a group of cells open upon click?

    Thats what I was looking for butcan you help me out how to use it in my sheets (Im kinda new learner :p )

  18. #18
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,049

    Re: Make a group of cells open upon click?

    Quote Originally Posted by Adnanbaig View Post
    Thats what I was looking for butcan you help me out how to use it in my sheets (Im kinda new learner :p )
    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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