Consulting

Results 1 to 3 of 3

Thread: Add formula to cell

  1. #1

    Add formula to cell

    Hello
    I wrote a long formula in excel and i want to save time by insert it with code.
    The formula is :
    "=IF(ISERROR(VLOOKUP($A73,Sheet1!$A$1:$M$173,10,0))=TRUE,0,VLOOKUP($A73,She et1!$A$1:$M$173,10,0))"

    What should i write in order to insrt it by code ?

    Help is needed

    Thanks

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    You can insert a formula as a range name and call it as in =Test
    or
    [VBA]
    ActiveCell.Formula = "=IF(ISERROR(VLOOKUP($A73,Sheet1!$A$1:$M$173,10,0))=TRUE,0,VLOOKUP($A73,She et1!$A$1:$M$173,10,0))"

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Unnecessary test for TRUE

    [vba]

    ActiveCell.Formula = "=IF(ISERROR(VLOOKUP($A73,Sheet1!$A$1:$M$173,10,0)),0,VLOOKUP($A73,Sheet1!$ A$1:$M$173,10,0))"
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •