VBA - Adding a therm on a formula already exist in a cell

  • Hi guys, my question is simples. I have this code, running just fine, but now I need to add something in it.


    Code
    Set b = .Range("D" & First2, "D" & Last2 + QtP)For Each cell2 In b
    If cell2.Interior.ColorIndex <> xlNone Then
        .Range("D4").Value = "=" & cell2.Address
    End If
    Next cell2


    As you can see, he searches which cell it's colored and then reference in the Cell "D4". But I need sum one cell (always fixed coordenates), so that in the cell something like: "=R$4 + T$11". R$4 just example, that my code is already finding, and I need to add the cell T11.


    I tried a few variations but I can't get through.


    Code
    .Range("E4").Value = "=" & cell2.Offset(0, 1).Address + T$11"
    .Range("E4").Value = "='" & cell2.Offset(0, 1).Address + "'T$11"
    .Range("E4").Value = "=" & cell2.Offset(0, 1).Address + .Range("T11").Address"


    thanks in advance.

  • Re: VBA Excel - Adding a therm on a formula already exist in a cell.


    Hi AlanSidman, that work, but I need to put a formula in the cell, not only the result.


    Any sugestions?

  • Re: VBA Excel - Adding a therm on a formula already exist in a cell.


    what formula? please explain in more detail as I am not understanding your requirement. Upload a spreadsheet if necessary to help with your explanation with examples.

  • Re: VBA Excel - Adding a therm on a formula already exist in a cell.


    Try this

    Code
    .Range("E4").Formula = "=sum(" & cell2.Offset(0, 1).Address & ",$T$11)"

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!