+ Reply to Thread
Results 1 to 11 of 11

Use cell address, not its value, as a function argument

  1. #1
    Registered User
    Join Date
    06-10-2014
    Location
    Brooklyn Heights
    MS-Off Ver
    Office Professional Plus 2013
    Posts
    16

    Use cell address, not its value, as a function argument

    (sorry about the massive subject title - accidentally hit entry before proofing)

    ________________________
    it's been forever since i programmed in excel; and, of all things, i'm stuck at XL101

    the formula starts
    Function Sum_till_blank(rTarget As Range, vOffset As Integer)

    where rtarget ought to be a cell ADDRESS, and vOffset is a number
    for a in-cell formula entry "= Sum_till_blank(B29,3)"
    the arguments received are
    rTarget = "the value of cell B29", NOT the cell address (which is what i want)

    it's such a simple issue, continual web searching is making me insane


    with much thanks in advance,
    mark
    Last edited by 6StringJazzer; 03-15-2018 at 09:39 PM. Reason: clarified title

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: enter cell adresns as a formula arguement, not it value

    Probably:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    06-10-2014
    Location
    Brooklyn Heights
    MS-Off Ver
    Office Professional Plus 2013
    Posts
    16

    Re: enter cell adresns as a formula arguement, not it value

    nope, (sorry)
    just for ref, here's the whole snippet:

    Please Login or Register  to view this content.
    Last edited by 6StringJazzer; 03-15-2018 at 09:38 PM. Reason: code tags

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: enter cell adresns as a formula arguement, not it value

    What are the arguments that you're entering for the function?

    BTW: Your post 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.

    Click on Edit to open your thread, then 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

  5. #5
    Registered User
    Join Date
    06-10-2014
    Location
    Brooklyn Heights
    MS-Off Ver
    Office Professional Plus 2013
    Posts
    16

    Re: enter cell adresns as a formula arguement, not it value

    apologies for the lack of
    Please Login or Register  to view this content.
    ; i did look for them, as an auto format; never dawned on me to just type them in .

    (if I understand your ? correctly)
    the in-cell formula entry is: = Sum_till_blank(B29,3)

    ...and my hunch is that's where the problem is: "b29" being a reference to a cell, of course the value passed is such and not the address "B29"
    I tried changing that to: = Sum_till_blank("B29",3) - i knew that wasn't going to work (AH! I was right !)

    Please Login or Register  to view this content.

  6. #6
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,953

    Re: enter cell adresns as a formula arguement, not it value

    That code has several problems. Please explain what it is supposed to do (explain the logic).
    Ben Van Johnson

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: enter cell adresns as a formula arguement, not it value

    This combination might be what you want

    Please Login or Register  to view this content.
    Last edited by xladept; 03-15-2018 at 05:37 PM.

  8. #8
    Registered User
    Join Date
    06-10-2014
    Location
    Brooklyn Heights
    MS-Off Ver
    Office Professional Plus 2013
    Posts
    16

    Re: enter cell adresns as a formula arguement, not it value

    the spread sheet has consecutive entries in # number of rows (and that number can vary significantly -usually between 1 and 15-ish without rhyme nor reason), followed by at least one blank row, then again by entries in # rows and another blank row, and on again

    i want to sum of all of the values in one of the columns for each range of entires


    i'm checking the value of a cell in the first row (let's say it's in column (ex: D), that column will always have entries),
    then adding the value of an offset column in that row to the total (that offset can also vary... let's say it is an offset of 3, so the value would be in column: G)

    then looping the code to check the next row (row +1)
    if the column D cell of that row has an entry, then the value of column G is added to the sum (column G may or may not have an entry, and this is OK)
    ...continue checking to the next row below, and so forth
    if the column D cell is empty (= ""), then you've arrive at the end of that block of data entry, and the total will be the formula result

    ----------------
    the usual method has been to use sum() for that range; continually adjusting where the range is. it may be the sum of 2 rows, or of 14; this approach requires continual updating (at each range / checking / correcting...) and is frequently WRONG.

  9. #9
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,953

    Re: enter cell adresns as a formula arguement, not it value

    Please Login or Register  to view this content.
    * no workbook to test with
    Last edited by protonLeah; 03-15-2018 at 07:11 PM.

  10. #10
    Registered User
    Join Date
    06-10-2014
    Location
    Brooklyn Heights
    MS-Off Ver
    Office Professional Plus 2013
    Posts
    16

    Re: enter cell adresns as a formula arguement, not it value

    it sort of worked, but then in noticed that block bottoms were not always correct;
    but when i put it in the attached (which is similar except that the values to be summed are formulas - which would most typically be the case...)

    attached is a simplified test workbook (but only if your OK with having a look)
    ...never kick a gift horse in the mouth by mom would say!
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    06-10-2014
    Location
    Brooklyn Heights
    MS-Off Ver
    Office Professional Plus 2013
    Posts
    16

    Re: enter cell adresns as a formula arguement, not it value

    but this (and it may not be the most eloquent of code...) WORKED !!!

    Please Login or Register  to view this content.

+ 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] If cell meets date requirement enter 1, if not enter 0, if blank don't enter anything.
    By billrogers184 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-11-2017, 02:04 PM
  2. VBA to enter formula in cell not calculating...showing formula in cell
    By kmlloyd in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-09-2015, 06:42 PM
  3. [SOLVED] Enter formula result from one cell into a COUNTIF formula in another cell. Help please!
    By gregrach in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-10-2014, 11:23 AM
  4. Replies: 1
    Last Post: 11-08-2013, 02:06 AM
  5. IF arguement
    By OdinSmasher in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 01-28-2008, 03:56 PM
  6. Sub as an arguement
    By SuitedAces in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 09-07-2007, 08:46 PM

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