Excel VB Code - Formula Reference Cell

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MAdcock
    New Member
    • Nov 2006
    • 13

    Excel VB Code - Formula Reference Cell

    I have been having major problems trying to write a piece of code to basically tally (add) values in a table (column B) that have the same product name (column A). The problem is that the table is variable (produced from another macro) and so this needs to be taken into account.

    To solve the problem it could be performed through using the product name to know which values to add OR as I have already got another column(E) that has a count of how many of each of the products are contained in the table - that could be used to add the values as the table is sorted by product name (Column A).

    Otherwise, if that isnt possible, can someone tell if it is possible to make the following or similar formula to use the value contained within a cell instead of -8.

    ActiveCell.Form ulaR1C1 = "=SUM(R[-8]C[-1]:R[0]C[-1])"

    To Become For Example?:

    ActiveCell.Form ulaR1C1 = "=SUM(R[E1]C[-1]:R[0]C[-1])"

    If anyone can help, please let me know ASAP.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by MAdcock
    I have been having major problems trying to write a piece of code to basically tally (add) values in a table (column B) that have the same product name (column A). The problem is that the table is variable (produced from another macro) and so this needs to be taken into account.

    To solve the problem it could be performed through using the product name to know which values to add OR as I have already got another column(E) that has a count of how many of each of the products are contained in the table - that could be used to add the values as the table is sorted by product name (Column A).

    Otherwise, if that isnt possible, can someone tell if it is possible to make the following or similar formula to use the value contained within a cell instead of -8.

    ActiveCell.Form ulaR1C1 = "=SUM(R[-8]C[-1]:R[0]C[-1])"

    To Become For Example?:

    ActiveCell.Form ulaR1C1 = "=SUM(R[E1]C[-1]:R[0]C[-1])"

    If anyone can help, please let me know ASAP.
    The Indirect function might be some help there. To make use of it, you might need to use $A$1 format rather than R1C1 format, but I'm not sure.

    Comment

    Working...