+ Reply to Thread
Results 1 to 7 of 7

Getting the address "argument cel" from a function

  1. #1
    Registered User
    Join Date
    06-20-2013
    Location
    Trondheim, Norway
    MS-Off Ver
    Excel 2010
    Posts
    7

    Getting the address "argument cel" from a function

    Hi

    I'm trying to figure out how I can get the address from a argument to a function. I've found a similar thread, but I didn't get the answer to work for me. I am new to VBA-programing, so detalied answers is very appreciated.

    What I want my code to do is multiply one cel with an other cel, both being arguments to the function. But if the first argumet cel is emty or 0, I want the function to multiply the second argument with the cel to the left of argument one.

    Is this possible?

    Thanks in advance
    Mikkel

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Getting the address "argument cel" from a function

    if you are calling the function from a cell I suggest you change the call to pass whichever cell is appropriate as the argument rather than have the function refer to another cell indirectly. you could also pass all three cells as direct arguments if you prefer
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: Getting the address "argument cel" from a function

    Hi
    I am not in my office today so hopefully my explanation will make sense without being able to test it first.
    Lets say you have the following on a worksheet:
    A. B. C. D. E
    1. 3. 4. 5
    Your formula should be something like this:
    =IF(B2 <="0", C2*A1, IF (B2 >"0", C2*B2))
    Hope this helps.
    Good luck.
    Tony

  4. #4
    Registered User
    Join Date
    06-20-2013
    Location
    Trondheim, Norway
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Getting the address "argument cel" from a function

    I'll try to explain my problem as exact as I can now, as I see the ideas for workarounds ar many.

    I have a worksheet with three and three cells being merged on the first row, and the second row is normal. I want to multiply the first row with the second row. If I use "=A1*B1", and drag the formula out as many collums as I have on the row above, I only get the right calculation every third cell. This due to cell B1, C1, E1, F1, .. and so on are 0.

    So I thought I could make a macro, public function, that handles this for me. As of such finding the first cell address in any number of merged cell on one row. Doing this by checking if the argument cell is emty, or 0. Then if it is, check the cell to the left. And doing this for a set number of times, or until it finds a value other then zero.

    Hope this clearify my problem, or challenge.

    If there is an option on making all the cell-addresses in a merged cell contain the given value in the merged cell. That would be an easy fix. But not as fun.

    Thanks for replys.
    Mikkel

  5. #5
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Getting the address "argument cel" from a function

    Why not use this?

    Please Login or Register  to view this content.
    Please click the * below if this helps
    Please click the * below if this helps

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Getting the address "argument cel" from a function

    perhaps
    Please Login or Register  to view this content.
    then use
    =MergeValue(A1)*A2
    and copy across

  7. #7
    Registered User
    Join Date
    06-20-2013
    Location
    Trondheim, Norway
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Getting the address "argument cel" from a function

    JosephP: It didn't "answer" the topic, but it sure did exactly what I needed. Thanks.

    JasperD: I haven't been able to try your solution yet, and I'm not familiar enught with VBA to read out what your function does exactly. I'll look at it som more later this evening. Thanks for reply.

+ 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