Formula to let me know if my sales drop off

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
I thought this would be simple but it proving to be a challenge please help if you can.

I have a set of data that shows me how many items of a product I sell each month
What I want to identify if if a product was selling well, suddenly stoped selling then began selling again,
So let takr range "BE53:CO53" in in cell Cp35 id like a formula that tells me if sales drop off,
So it starts at BE53, If BE53 is a zero the it finds the first cell with a value greater than zero, If it doesn't find one then it returns "No Drop"
if it find a cell where the value is greater than zero, then it looks to see if any cells after that cell are zero, If it doesn't find one then it returns "No Drop"
If it find another zero then it looks to see if after that zero there is a cell with a value greater than zero, If it doesn't find one then it returns "No Drop"
if it find on it return "Contains Drop"

Please help if you can
Thanks
Tony
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Try the following UDF:

VBA Code:
Function drop_off(rng As Range)
  Dim i As Long, j As Long, k As Long, n As Long, z As Long
  Dim cIni As Long, cFin As Long, nRow As Long
  Dim res As String
  
  nRow = rng.Cells(1).Row
  cIni = rng.Cells(1).Column
  cFin = rng.Columns.Count + cIni - 1
  For i = cIni To cFin
    If Cells(nRow, i) <> "" And Cells(nRow, i) = "0" Then
      If i < cFin Then z = i + 1 Else z = i
      n = WorksheetFunction.Count(Range(Cells(nRow, z), Cells(nRow, cFin)), ">0")
      If n = 0 Then
        'So it starts at BE53, If BE53 is a zero the it
        'finds the first cell with a value greater than zero,
        'If it doesn't find one then it returns "No Drop"
        res = "No Drop"
        Exit For
      Else
        For j = z To cFin
          If Cells(nRow, j) > 0 Then
            If j < cFin Then z = j + 1 Else z = j
            n = WorksheetFunction.Count(Range(Cells(nRow, z), Cells(nRow, cFin)), "=0")
            If n = 0 Then
              'if it find a cell where the value is greater than zero,
              'then it looks to see if any cells after that cell are zero,
              'If it doesn't find one then it returns "No Drop"
              res = "No Drop"
              Exit For
            Else
              If j < cFin Then z = j + 1 Else z = j
              For k = z To cFin
                If Cells(nRow, k) <> "" And Cells(nRow, k) = 0 Then
                  If k < cFin Then z = k + 1 Else z = k
                  n = WorksheetFunction.Count(Range(Cells(nRow, z), Cells(nRow, cFin)), ">0")
                  If n = 0 Then
                    'If it find another zero then it looks to see if after that zero
                    'there is a cell with a value greater than zero,
                    'If it doesn't find one then it returns "No Drop"
                    res = "No Drop"
                  Else
                    'if it find on it return "Contains Drop"
                    res = "Contains Drop"
                  End If
                  Exit For
                End If
              Next
              If res <> "" Then Exit For
            End If
          End If
        Next
        If res <> "" Then
          Exit For
        End If
      End If
    ElseIf Cells(nRow, i) > 0 Then
            If i < cFin Then z = i + 1 Else z = i
            n = WorksheetFunction.Count(Range(Cells(nRow, z), Cells(nRow, cFin)), "=0")
            If n = 0 Then
              res = "No Drop"
              Exit For
            Else
              For k = z To cFin
                If Cells(nRow, k) <> "" And Cells(nRow, k) = 0 Then
                  If k < cFin Then z = k + 1 Else z = k
                  n = WorksheetFunction.Count(Range(Cells(nRow, z), Cells(nRow, cFin)), ">0")
                  If n = 0 Then
                    res = "No Drop"
                  Else
                    res = "Contains Drop"
                  End If
                  Exit For
                End If
              Next
              If res <> "" Then Exit For
            End If
    End If
  Next
  drop_off = res
End Function
Review the following scenarios:
Dante Amor
BDBEBFBGBHBIBJBKBLBMBNCOCPCQ
530No Drop
5402No Drop
55020No Drop
560203Contains Drop
57 
580No Drop
5902No Drop
60020No Drop
610203Contains Drop
622No Drop
6320No Drop
64203Contains Drop
652No Drop
6620No Drop
67203Contains Drop
Hoja4
Cell Formulas
RangeFormula
CQ53:CQ67CQ53=drop_off(BE53:CO53)
 
Upvote 0
Solution
Im glad to help you, thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top