+ Reply to Thread
Results 1 to 5 of 5

Adding formula to a cell with VB

  1. #1
    Registered User
    Join Date
    11-04-2004
    Posts
    8

    Adding formula to a cell with VB

    Hi

    I need to add a formula to a cell ( actually a range of cells) uing VB.

    The formula is

    =IF($U6="","",IF(OR($T6="Yes",$U6="Yes"),"HICA",IF($E6="No Notice","CALL","Notice")))

    I would like to use something like:

    Range("V2").Formula = "=IF(OR(T2="Yes",U2="Yes"),"HICA",IF(E2="No Notice","CALL","Notice"))"


    My problem is that the quotes in the formula are read as the end of the string in the vb. Could anyone help please?

    Thanks

  2. #2
    Registered User
    Join Date
    07-24-2006
    Posts
    6
    You need to use double (double double!) quotes:

    Range("V2").Formula = "=IF(OR(T2=""Yes"",U2=""Yes""),""HICA"",IF(E2=""No Notice"",""CALL"",""Notice""))"

  3. #3
    Registered User
    Join Date
    11-04-2004
    Posts
    8

    Thanks

    Thanks - I knew it was something simple.

  4. #4
    NickH
    Guest

    Re: Adding formula to a cell with VB


    Willow,

    The easiest way to get this right is to turn on the recorder and then
    enter the formula into the cell.

    Kind regards,
    NickH


  5. #5
    NickH
    Guest

    Re: Adding formula to a cell with VB


    Willow,

    The easiest way to get this right is to turn on the recorder and then
    enter the formula into the cell.

    Kind regards,
    NickH


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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