+ Reply to Thread
Results 1 to 10 of 10

Populating Adjacent Cells from a Function

  1. #1
    Registered User
    Join Date
    07-27-2014
    Location
    London
    MS-Off Ver
    2007
    Posts
    16

    Question Populating Adjacent Cells from a Function

    Hi Guys,

    Trying to figure out how to populate adjacent cells from a function. I have been searching threads and general consensus seems to be that this is not possible. However I have seen a number of examples of this happening, but the code is always locked, most famously probably would be the Bloomberg BDS and BDH formula.

    Can Anyone advise on how I would go about this? Every method I've tried doesn't work, my only thought is something like an event sub procedure, but I can't find an example of e.g. onfunctionrun event subprocedure, but can't find an example of this event code either.

    Much Appreciated!

  2. #2
    Valued Forum Contributor
    Join Date
    07-07-2014
    Location
    Washington DC
    MS-Off Ver
    2007
    Posts
    1,047

    Re: Populating Adjacent Cells from a Function

    Can you upload a sample file showing what you'd ideally like to accomplish? As in, what data you'd have BEFORE and what results you'd like AFTER?

  3. #3
    Registered User
    Join Date
    07-27-2014
    Location
    London
    MS-Off Ver
    2007
    Posts
    16

    Re: Populating Adjacent Cells from a Function

    Hi, sure

    Please Login or Register  to view this content.
    So purpose of this function is to take the range tdata, then return the full data from all columns up to 'norank' number of ranked items based of the sortc, column. works fine, the issue is wants it to populate the array into a grid below and right of the cell with the fucntion in it.

    Much appreciated!
    Last edited by vbalearnerSF; 08-05-2014 at 03:38 PM.

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

    Re: Populating Adjacent Cells from a Function

    Can you attach a workbook that shows what you want the function to do?

    This will return an array of the values of tdata, sorted.

    Select a range the same size as tdata and enter =Ranking(...) as an array formula

    Please Login or Register  to view this content.
    Last edited by mikerickson; 08-05-2014 at 12:49 PM.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Registered User
    Join Date
    07-27-2014
    Location
    London
    MS-Off Ver
    2007
    Posts
    16

    Re: Populating Adjacent Cells from a Function

    Thanks for the response! At the office so uploading the actual sheet might cause me compliance issues, so e.g. take

    70 Mandy
    67 Ken
    90 Kathy
    92 Bill
    56 Wendy
    98 Tom
    65 Candy
    60 Tim

    =Ranking(datarange, 1, 4)

    then have it populate

    98 Tom
    92 Bill
    90 Kathy
    70 Mandy

    in A1:B4 assuming the above formula was in A1

    Aware of the above mentioned option but its somewhat inelegant and I've seen formulas that get around this. Any thoughts?

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

    Re: Populating Adjacent Cells from a Function

    Then I'd use

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    07-27-2014
    Location
    London
    MS-Off Ver
    2007
    Posts
    16

    Re: Populating Adjacent Cells from a Function

    Hmmm tried that but doesn't populate a grid for me? just populates the cell with function in it, with the rank 1 value?

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Populating Adjacent Cells from a Function

    Hi, vbalearnerSF,

    Your post #3 does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  9. #9
    Registered User
    Join Date
    07-27-2014
    Location
    London
    MS-Off Ver
    2007
    Posts
    16

    Re: Populating Adjacent Cells from a Function

    Hi Holger,

    I have changed it per your request thanks for letting me know!

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

    Re: Populating Adjacent Cells from a Function

    That UDF returns an array. A worksheet formula that uses it has to be entered as an array formula.

    Select a range the same size as data, type the formula in the formula bar and press Ctrl-Shift-Enter.

  11. #11
    Registered User
    Join Date
    07-27-2014
    Location
    London
    MS-Off Ver
    2007
    Posts
    16

    Re: Populating Adjacent Cells from a Function

    Thanks I know about setting it as an array function thats what I was referring to with 'Aware of the above mentioned option but its somewhat inelegant and I've seen formulas that get around this. Any thoughts?'

    The downside of this is the having to do it on the multiple cells, the function I've seen is far more elegant, it populates all the cells as described, with only the top left cell containing the formula. The primary benefit of it is that its easily used by low skill excel users, as this is the end goal of the function.

+ 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. [SOLVED] Populating Cells with Formulas Based on Adjacent Cell
    By eoghanmolloy in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-03-2014, 04:34 AM
  2. Populating Cells on Drop Down Select - Not sure what function to use
    By vricci in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-29-2013, 10:06 PM
  3. [SOLVED] Populating subcategory cells with adjacent text from category cells
    By MrRed in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-25-2012, 08:21 AM
  4. Replies: 5
    Last Post: 10-07-2011, 08:46 AM
  5. Trouble Populating Adjacent Cells Using Drop Down Lists
    By onlineeng in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-25-2011, 10:33 PM

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