+ Reply to Thread
Results 1 to 10 of 10

Formulas

Hybrid View

  1. #1
    Abilio
    Guest

    Formulas

    I have this formula that calculates correctly the sheet1 but for some reason
    it doesn't calculates the sheet2. I'd appreciate the help.



    Function Projection() 'This step calculates projections, it should be
    'done in both of the Sheet1 and Sheet2.

    With Worksheets("Sheet1")
    ..Range("Q2:Q" & Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    End With
    With Worksheets("Sheet2")
    ..Range("Q2:Q" & Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    End With
    End Function



  2. #2
    Martin Krastev
    Guest

    RE: Formulas

    I guess you will have to put a dot (".") before Cells!

    "Abilio" wrote:

    > I have this formula that calculates correctly the sheet1 but for some reason
    > it doesn't calculates the sheet2. I'd appreciate the help.
    >
    >
    >
    > Function Projection() 'This step calculates projections, it should be
    > 'done in both of the Sheet1 and Sheet2.
    >
    > With Worksheets("Sheet1")
    > .Range("Q2:Q" & Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    > "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    > End With
    > With Worksheets("Sheet2")
    > .Range("Q2:Q" & Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    > "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    > End With
    > End Function
    >
    >


  3. #3
    Abilio
    Guest

    RE: Formulas

    do You mean after & ? if so, It didn't work.

    "Martin Krastev" wrote:

    > I guess you will have to put a dot (".") before Cells!
    >
    > "Abilio" wrote:
    >
    > > I have this formula that calculates correctly the sheet1 but for some reason
    > > it doesn't calculates the sheet2. I'd appreciate the help.
    > >
    > >
    > >
    > > Function Projection() 'This step calculates projections, it should be
    > > 'done in both of the Sheet1 and Sheet2.
    > >
    > > With Worksheets("Sheet1")
    > > .Range("Q2:Q" & Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    > > "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    > > End With
    > > With Worksheets("Sheet2")
    > > .Range("Q2:Q" & Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    > > "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    > > End With
    > > End Function
    > >
    > >


  4. #4
    Martin Krastev
    Guest

    RE: Formulas

    Function Projection() 'This step calculates projections, it should be
    'done in both of the Sheet1 and Sheet2.

    With Worksheets("Sheet1")
    ..Range("Q2:Q" & .Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    End With
    With Worksheets("Sheet2")
    ..Range("Q2:Q" & .Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    End With
    End Function


    "Abilio" wrote:

    > do You mean after & ? if so, It didn't work.
    >
    > "Martin Krastev" wrote:
    >
    > > I guess you will have to put a dot (".") before Cells!
    > >
    > > "Abilio" wrote:
    > >
    > > > I have this formula that calculates correctly the sheet1 but for some reason
    > > > it doesn't calculates the sheet2. I'd appreciate the help.
    > > >
    > > >
    > > >
    > > > Function Projection() 'This step calculates projections, it should be
    > > > 'done in both of the Sheet1 and Sheet2.
    > > >
    > > > With Worksheets("Sheet1")
    > > > .Range("Q2:Q" & Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    > > > "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    > > > End With
    > > > With Worksheets("Sheet2")
    > > > .Range("Q2:Q" & Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    > > > "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    > > > End With
    > > > End Function
    > > >
    > > >


  5. #5
    Abilio
    Guest

    RE: Formulas

    It is still deleting the sheet2 and gives no results

    "Martin Krastev" wrote:

    > Function Projection() 'This step calculates projections, it should be
    > 'done in both of the Sheet1 and Sheet2.
    >
    > With Worksheets("Sheet1")
    > .Range("Q2:Q" & .Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    > "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    > End With
    > With Worksheets("Sheet2")
    > .Range("Q2:Q" & .Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    > "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    > End With
    > End Function
    >
    >
    > "Abilio" wrote:
    >
    > > do You mean after & ? if so, It didn't work.
    > >
    > > "Martin Krastev" wrote:
    > >
    > > > I guess you will have to put a dot (".") before Cells!
    > > >
    > > > "Abilio" wrote:
    > > >
    > > > > I have this formula that calculates correctly the sheet1 but for some reason
    > > > > it doesn't calculates the sheet2. I'd appreciate the help.
    > > > >
    > > > >
    > > > >
    > > > > Function Projection() 'This step calculates projections, it should be
    > > > > 'done in both of the Sheet1 and Sheet2.
    > > > >
    > > > > With Worksheets("Sheet1")
    > > > > .Range("Q2:Q" & Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    > > > > "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    > > > > End With
    > > > > With Worksheets("Sheet2")
    > > > > .Range("Q2:Q" & Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    > > > > "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    > > > > End With
    > > > > End Function
    > > > >
    > > > >


  6. #6
    Martin Krastev
    Guest

    RE: Formulas

    Do I understand you correctly that you want to put the formula
    =IF(L2=0,-999999,M2/L2*H2*13300)
    in cell Q2 (and below until the # of rows in col h) of both sheets 1 and 2.

    Or you want the formula on sheet2 to refer to cells in sheet1?

    "Abilio" wrote:

    > It is still deleting the sheet2 and gives no results
    >
    > "Martin Krastev" wrote:
    >
    > > Function Projection() 'This step calculates projections, it should be
    > > 'done in both of the Sheet1 and Sheet2.
    > >
    > > With Worksheets("Sheet1")
    > > .Range("Q2:Q" & .Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    > > "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    > > End With
    > > With Worksheets("Sheet2")
    > > .Range("Q2:Q" & .Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    > > "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    > > End With
    > > End Function
    > >
    > >
    > > "Abilio" wrote:
    > >
    > > > do You mean after & ? if so, It didn't work.
    > > >
    > > > "Martin Krastev" wrote:
    > > >
    > > > > I guess you will have to put a dot (".") before Cells!
    > > > >
    > > > > "Abilio" wrote:
    > > > >
    > > > > > I have this formula that calculates correctly the sheet1 but for some reason
    > > > > > it doesn't calculates the sheet2. I'd appreciate the help.
    > > > > >
    > > > > >
    > > > > >
    > > > > > Function Projection() 'This step calculates projections, it should be
    > > > > > 'done in both of the Sheet1 and Sheet2.
    > > > > >
    > > > > > With Worksheets("Sheet1")
    > > > > > .Range("Q2:Q" & Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    > > > > > "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    > > > > > End With
    > > > > > With Worksheets("Sheet2")
    > > > > > .Range("Q2:Q" & Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    > > > > > "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    > > > > > End With
    > > > > > End Function
    > > > > >
    > > > > >


  7. #7
    Duke Carey
    Guest

    RE: Formulas

    Try making this a sub and not a function.


    "Abilio" wrote:

    > I have this formula that calculates correctly the sheet1 but for some reason
    > it doesn't calculates the sheet2. I'd appreciate the help.
    >
    >
    >
    > Function Projection() 'This step calculates projections, it should be
    > 'done in both of the Sheet1 and Sheet2.
    >
    > With Worksheets("Sheet1")
    > .Range("Q2:Q" & Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    > "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    > End With
    > With Worksheets("Sheet2")
    > .Range("Q2:Q" & Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    > "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    > End With
    > End Function
    >
    >


  8. #8
    Abilio
    Guest

    RE: Formulas

    How do I do it?

    "Duke Carey" wrote:

    > Try making this a sub and not a function.
    >
    >
    > "Abilio" wrote:
    >
    > > I have this formula that calculates correctly the sheet1 but for some reason
    > > it doesn't calculates the sheet2. I'd appreciate the help.
    > >
    > >
    > >
    > > Function Projection() 'This step calculates projections, it should be
    > > 'done in both of the Sheet1 and Sheet2.
    > >
    > > With Worksheets("Sheet1")
    > > .Range("Q2:Q" & Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    > > "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    > > End With
    > > With Worksheets("Sheet2")
    > > .Range("Q2:Q" & Cells(.Rows.Count, 8).End(xlUp).Row).FormulaR1C1 = _
    > > "=IF(RC[-5]=0,-999999,(RC[-4]/(RC[-5]*RC[-9]))*13300)"
    > > End With
    > > End Function
    > >
    > >


+ 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