+ Reply to Thread
Results 1 to 6 of 6

Replace #N/A by a formula

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-18-2012
    Location
    ardeduck schools
    MS-Off Ver
    Excel 2003
    Posts
    100

    Replace #N/A by a formula

    Hello,

    I'd like to know how could I replace the #N/A by a specific formula that will do the following
    At the first date when a stock has a data, apply a formula which is (First day of quotation of stock B / this same day of stock A) * (stock A -1day)

    Please look at the screenshot with explanations I made
    explication excel vlookup et conditions en.jpg


    And here is my code
    'DEBUT TEST VLOOOKUP FORMULE EXCEL
    
         LgDep = 2   ' Ligne de départ du tableau dans la page Sheet2
      ClDep = 2   ' Colonne de départ du tableau dans la page Sheet2
    
      With Sheets("Sheet2")
        ClFin = .Cells(LgDep, Columns.Count).End(xlToLeft).Column
        LgFin = .Range(.Cells(1, ClDep), .Cells(1, ClFin)).EntireColumn.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
      End With
      Nblg = Range("A" & Rows.Count).End(xlUp).Row
      For i = ClDep To ClFin Step 2
        With Range(Cells(2, 2 + (i - ClDep) / 2), Cells(Nblg, 2 + (i - ClDep) / 2))
          .Formula = "=VLOOKUP(RC1,Sheet2!R" & LgDep & "C" & i & ":R" & Nblg & "C" & i + 1 & ",2,TRUE)"
        End With
      Next i
    
    'FIN TEST VLOOOKUP FORMULE EXCEL
    And here is the link to the file https://docs.google.com/open?id=0B1X...1d0dW9yOEs0NmM

    Best regards,

    R
    Last edited by bryan444; 12-07-2012 at 07:55 AM.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Replace #N/A by a formula

    Maybe replace this:

    .Formula = "=VLOOKUP(RC1,Sheet2!R" & LgDep & "C" & i & ":R" & Nblg & "C" & i + 1 & ",2,TRUE)"
    with this?

    .Formula = "=IF(ISNA(VLOOKUP(RC1,Sheet2!R" & LgDep & "C" & i & ":R" & Nblg & "C" & i + 1 & ",2,TRUE),$F$6510/$E$6510*E6509,VLOOKUP(RC1,Sheet2!R" & LgDep & "C" & i & ":R" & Nblg & "C" & i + 1 & ",2,TRUE)"

  3. #3
    Forum Contributor
    Join Date
    10-18-2012
    Location
    ardeduck schools
    MS-Off Ver
    Excel 2003
    Posts
    100

    Re: Replace #N/A by a formula

    Thanks!
    But not working... :-(

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Replace #N/A by a formula

    What does it return?

  5. #5
    Forum Contributor
    Join Date
    10-18-2012
    Location
    ardeduck schools
    MS-Off Ver
    Excel 2003
    Posts
    100

    Re: Replace #N/A by a formula

    error 1004, yellowing the formula

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Replace #N/A by a formula

    Try replacing with this:

    .Formula = "=IF(ISNA(VLOOKUP(RC1,Sheet2!R" & LgDep & "C" & i & ":R" & Nblg & "C" & i + 1 & ",2,TRUE),SUM($F$6510/$E$6510)*E6509,VLOOKUP(RC1,Sheet2!R" & LgDep & "C" & i & ":R" & Nblg & "C" & i + 1 & ",2,TRUE)"

+ 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