• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Count number of zero occurrences

Hi,

Can someone please help me how to put a formula or a VBA code to count the number of occurrences a certain material will reach the ZERO status.

This is a monitoring database of our stocks and I would like to put a counter on the yellow column on the attached file, every time it will display a ZERO status. This will also help us to measure the capacity of our personnel to maintain the status of each material at GOOD level.

Hope you can help me with this.

A sample file is attached for your reference.

Thank you!
 

Attachments

  • Critical Stock Level_.xlsx
    249.8 KB · Views: 11
Add the following code to the Stock Level Monitoring module in VBA

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Range("I" & Target.Row).Text = "ZERO" Then
 Range("J" & Target.Row).Value = Range("J" & Target.Row).Value + 1
End If
Application.EnableEvents = True
End Sub


upload_2016-6-21_9-53-20.png

Save the file as a *.xlsm file type
enjoy
 
Hi Hui ,

Probably you can also have a Workbook_Open procedure to initialize the cells if they do not already have a non-zero value , and the status in column I is ZERO.

Narayan
 
I'm sure the logic I applied above is not comprehensive enough as it is
But it can be built on
 
Hi Sir Hui,

Thank you!
The code is very useful.
But I found out that the counter or the number on column J can be deleted manually, is there a way that this will not be deleted unless you reset the counter?

Also, if a reset button will be added, is it possible to be password protected such that I am the only one who can access it?

Thank you!
 
Hi Again,

I used the code given by Sir Hui and it was working properly.
Is it possible that whenever the counter counts it will record the number of days it stayed at zero thru the date today column and will stop counting at the date it was removed at the zero status?

My another problem is, what if the material reached the zero status more than once. I dunno how to reflect the number of days it reached zero for the second time. :(
 

Attachments

  • Critical Stock Level_.xlsm
    257.5 KB · Views: 2
Back
Top