placing a formula into a cell through vb

  • bleh...can't figure out what's wrong. I changed a numerical value in a formula to be inserted into a cell (0.5) into a variable (TaskLim). i had problems figuring out the ampersand & quote placements. i finally got it to stop giving me errors, but it now just gives me a "TRUE" in the cell, when I want the actual formula. Any ideas?

    Selection.Offset(3, 0).FormulaR1C1 = "=COUNTIF(R[-2]C, "">=0.5"")"

    Selection.Offset(3, 0).FormulaR1C1 = "=COUNTIF(R[-2]C, " & "" >= " & TaskLim & "")"

  • in order for VBA to read the " character, you will need to use:


    for example:

    MsgBox "The " & Chr(34) & " character has been printed"

    Also, if your unsure what you final formula will actually look like, try doing a MSGBOX of the formula your setting, and it will show you exactly what is wrong with it

Participate now!

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