none
Insert formula into a cell through VBA RRS feed

  • Question

  •    Cannot use this code to install a formula into a cell through VBA     Range("B9").Formula = "=SUM(=LEFT(T25, SEARCH("x",T25,1)-1))"
    Monday, August 20, 2018 4:52 AM

All replies

  • Hello peterhy1,

    Based on my test, please try the VBA code as below:

    Sub test()
    Range("B9").Formula = "=LEFT(T25, SEARCH(""x"",T25,1)-1)"
    End Sub

    Note that the double quotes " within the formula have been doubled to "". This is necessary because the entire formula is enclosed in double quotes.

    Best Regards,

    Yuki


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    • Proposed as answer by Simon Wu-MSFT Tuesday, August 28, 2018 7:59 AM
    Monday, August 20, 2018 6:52 AM
    Moderator
  • Thanks for you asking. Did you resolved your issue ? If the post helps you, you can mark it as answer and close the post.

    Best Regards,

    Yuki


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Wednesday, August 22, 2018 7:21 AM
    Moderator