+ Reply to Thread
Results 1 to 8 of 8

formula to return the ACTIVE cell's contents

  1. #1
    Forum Contributor
    Join Date
    08-17-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    158

    formula to return the ACTIVE cell's contents

    I found a forum post in excel solutions online and it did resolve an issue. However, I still need the formlua to do something else that the below formula does not do and am hoping someone might have the solution!

    I found this forum posted, please see below:


    Note: You can't use B:B or B1:B65536 or the formula returns an error. Use any other large row number.

    The formula listed below needs to be entered as array formula.

    If you want to return the cell's contents, use this formula:

    =INDEX(B1:B65000,MAX(IF(LEN(B1:B65000)>0,ROW(B1:B65000),0)),1)


    I am using the forumla to return the cell's contents. In my case, it is a text string. I have data validation lists in column B with several options. On a different worksheet, I have this formula. The problem I am having is if I change lets say B10, the formula does populate the text. Then I go to B11 and select a text from the list and the formula populates this text. But if I go back to B10, the formula will not populate the new text string from B10. (i.e. the formula doesn't recognize going upwards in a column, only downwards)

    As a result, I need the formula to be able to recognize ANY active cell in column B. If I have a user that is using my worksheet, I dont want them to have to go in order down rows one by one. If they would like to go from B15 back to B10 and select different text within the data validation list, they can do so and the formula will populate the new text string in B10. If you need more clarity, please let me know. HELLPPP!!

  2. #2
    Forum Contributor
    Join Date
    08-17-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    158

    Re: formula to return the ACTIVE cell's contents

    Does anyone have a response?? Please help!!

  3. #3
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: formula to return the ACTIVE cell's contents

    The formula you have returns value in the last non-blank row of Column B and not value of active cell
    Please Login or Register  to view this content.
    What you are trying to achieve is not possible without VBA.
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  4. #4
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: formula to return the ACTIVE cell's contents

    Enter the following User Defined Function in a standard module:

    Please Login or Register  to view this content.
    Insert the following event macro in the workbook code area:

    Please Login or Register  to view this content.
    You will get a warning about possible circular references, but it should be O.K.
    Pick a worksheet cell and enter:
    =ActiveCons()
    Last edited by Jakobshavn; 08-30-2012 at 06:26 PM. Reason: examples
    Gary's Student

  5. #5
    Forum Contributor
    Join Date
    08-17-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    158

    Re: formula to return the ACTIVE cell's contents

    Hey Jakobshavn,

    I did exactly what you said to do..and the cell that I put the formula =ActiveCons() only updates the first cell I click on. But it won't update on the cells I click on after that. For example, after following your steps the first cell I clicked on was B17 which had the text string "Event". The cell with the formula =ActiveCons() updated with "Event". The next cell I clicked on was B18 which had the text string "Trip", however the cell with the formula =ActiveCons() still stayed with "Event". Any other ideas? I appreciate the help!

  6. #6
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: formula to return the ACTIVE cell's contents

    Quote Originally Posted by bcn1988 View Post
    Note: You can't use B:B or B1:B65536 or the formula returns an error. Use any other large row number.
    this is not the case with Excel 2010. you can use whatever ranges that you want to, albeit, depending on the formula / function being employed, performance may be severely impeded.
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

  7. #7
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: formula to return the ACTIVE cell's contents

    Make sure Worksheet_SelectionChange is in the proper place. If it is in the same module as the function, erase it and follow these instructions:


    Because it is worksheet code, it is very easy to install and automatic to use:

    1. right-click the tab name near the bottom of the Excel window
    2. select View Code - this brings up a VBE window
    3. paste the stuff in and close the VBE window

    If you have any concerns, first try it on a trial worksheet.

    If you save the workbook, the macro will be saved with it.


    To remove the macro:

    1. bring up the VBE windows as above
    2. clear the code out
    3. close the VBE window

    To learn more about macros in general, see:

    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    To learn more about Event Macros (worksheet code), see:

    http://www.mvps.org/dmcritchie/excel/event.htm

  8. #8
    Forum Contributor
    Join Date
    08-17-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    158

    Re: formula to return the ACTIVE cell's contents

    These are the steps I took...

    1) Add new module in VBE.
    2) Entered the first code you gave me.

    3) Select the workbook node
    4) Pasted the code in this module.

    The only thing I can think of is I have am calling a macro for when I open the workbook and this is in the workbook module. So the code you gave me is the second sub code. Would this have any affect on your coding?
    5) Went to excel spreadsheet, and entered the formula =ActiveCons()

+ 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