+ Reply to Thread
Results 1 to 5 of 5

Find linked cell address

  1. #1
    Valued Forum Contributor
    Join Date
    01-08-2011
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2007 to 2016
    Posts
    456

    Find linked cell address

    I have a worksheet with several toggle buttons. When one of the toggle buttons is clicked it runs some code which checks the status of each toggle button (TRUE or FALSE), but I need to find the address of the linked cell to drive which columns to hide or display (I want to hide the two columns after the linked cell column), but I can't work out how to find the linked cell address.

    A sample worksheet is attached (the real one is a lot more complex!). Any help would be much appreciated.

    Many thanks
    Shirley
    Attached Files Attached Files
    Last edited by shirleyxls; 02-05-2011 at 07:13 PM. Reason: Changed to SOLVED

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Find linked cell address

    Hi Shirley,

    Clicking on those toggle buttons runs VBA code. If you go to the Developer Tab and look behind the sheet or in a module you will be able to see the code that is being called/run.

    Look at this picture http://www.exceldigest.com/myblog/20...developer-tab/ and find the Design Mode Icon. If you select this and then click and right click the toggle buttons you can see what macro they are using and what the code behind each is doing.

    hope that helps.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Valued Forum Contributor
    Join Date
    01-08-2011
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2007 to 2016
    Posts
    456

    Re: Find linked cell address

    Thanks for the quick reply Marvin.
    Maybe I wasn't clear, but I'm developing the code to run behind the toggle buttons rather than trying to see what someone else wrote. Each button calls the same macro (I didn't want to put the same code in every button - there will be 52 of them on the final version!) so my code needs to work out which button was switched on and take some action depending on the address of the cell linked to that button. But I can't figure out the VBA code to find the linked cell related to each button.
    Any ideas?
    Many thanks
    Shirley

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Find linked cell address

    Hi Shirley,

    ToggleButtons are really shapes on the form. They really don't "tie to a cell" as I understand it. Perhaps before you CallExpandCollapse you should put the name of the button clicked in a cell on your sheet somewhere. Then when you got to the called sub you could read the cell to see what ToggleButton was pressed.

    I'm imagining your code looking like:
    Please Login or Register  to view this content.
    Then when your get to your module code you see what is in A1 and branch based on it.

    I went through the Object Browser looking for the cell a shape is attached to and found the word "ShapeRange" but couldn't make it return useful information. (I really gave me an error message which told me, once again, "you don't understand this object")

    You could also declare a global variable and set it to the last button clicked and not need a cell in the workbook.
    Last edited by MarvinP; 02-05-2011 at 07:02 PM.

  5. #5
    Valued Forum Contributor
    Join Date
    01-08-2011
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2007 to 2016
    Posts
    456

    Re: Find linked cell address

    Hey, excellent idea! Wish I'd thought of that!

    I also tried the object browser before I posted my question, and also couldn't get anything relating to shapes to return any useful information, at least in this context.

    I'm sure that will solve my problem... many thanks for your help.
    Shirley

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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