+ Reply to Thread
Results 1 to 3 of 3

only display positive values

  1. #1
    Michael
    Guest

    only display positive values

    I have a spreadsheet that forecasts based on history, unfortunately where
    there have been negative sales the formula creates a negative forecast which
    I want to read as zero. I am using the macro below

    thanks

    Dim i As Long
    For i = 31 To Application.ActiveSheet.UsedRange.Rows.Count

    If Not Cells(i, "V").Locked Then _
    Cells(i, "V").FormulaR1C1 = "=SUM(RC15:RC17)/3"
    Cells(i, "V").Copy
    If Not Cells(i, "V").Locked Then _
    Cells(i, "V").PasteSpecial Paste:=xlValues

  2. #2
    Mike Fogleman
    Guest

    Re: only display positive values

    Try an IF statement in your formula:

    Cells(i, "V").FormulaR1C1 = "=IF(SUM(RC15:RC17)/3<0,0,SUM(RC15:RC17)/3)"

    Mike F

    "Michael" <Michael@discussions.microsoft.com> wrote in message
    news:5EBAFFAD-3EC1-462B-8D3B-77C16E869DD4@microsoft.com...
    >I have a spreadsheet that forecasts based on history, unfortunately where
    > there have been negative sales the formula creates a negative forecast
    > which
    > I want to read as zero. I am using the macro below
    >
    > thanks
    >
    > Dim i As Long
    > For i = 31 To Application.ActiveSheet.UsedRange.Rows.Count
    >
    > If Not Cells(i, "V").Locked Then _
    > Cells(i, "V").FormulaR1C1 = "=SUM(RC15:RC17)/3"
    > Cells(i, "V").Copy
    > If Not Cells(i, "V").Locked Then _
    > Cells(i, "V").PasteSpecial Paste:=xlValues




  3. #3
    K Dales
    Guest

    RE: only display positive values

    Cells(i, "V").FormulaR1C1 = "=IF(SUM(RC15:RC17)<0,0,SUM(RC15:RC17)</3)"
    --
    - K Dales


    "Michael" wrote:

    > I have a spreadsheet that forecasts based on history, unfortunately where
    > there have been negative sales the formula creates a negative forecast which
    > I want to read as zero. I am using the macro below
    >
    > thanks
    >
    > Dim i As Long
    > For i = 31 To Application.ActiveSheet.UsedRange.Rows.Count
    >
    > If Not Cells(i, "V").Locked Then _
    > Cells(i, "V").FormulaR1C1 = "=SUM(RC15:RC17)/3"
    > Cells(i, "V").Copy
    > If Not Cells(i, "V").Locked Then _
    > Cells(i, "V").PasteSpecial Paste:=xlValues


+ 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