• 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.

Implementing a coder in VBA code

luckyclochette

New Member
Dear all,


I have a set of experimental data where one of my parameters - the pressure - varies regularly. It increases when a robot is applying a polymer product and then decreases between two devices on the production line. I would like to count the number of increases by implementing a coder once the pressure is over 40 bars. Could anyone help me to do it properly ?


Thanks in advance,
 
Can you provide a (small) sample of what your data looks like, and what you expect to see?

Otherwise, a random guess would be a CF formula like:

=AND(Pressure>40,ThisPSI>LastPSI)
 
Dear Luke, is here a file where I show what I wish to do.

Thanks in advance for your help

[pre]
Code:
time         pressure coder
11:07:16,953	19	1
11:07:17,000	19	1
11:07:17,062	21	1
11:07:17,109	24	1
11:07:17,156	26	1
11:07:17,203	29	1
11:07:17,250	33	1
11:07:17,312	37	1
11:07:17,359	40	2
11:07:17,406	43	2
11:07:17,453	46	2
11:07:17,500	49	2
11:07:17,562	53	2
11:07:17,609	57	2
11:07:17,656	59	2
11:07:17,703	61	2
11:07:17,750	63	2
11:07:17,812	66	2
11:07:17,859	69	2
11:07:17,906	72	2
11:07:17,953	73	2
11:07:18,000	74	2
11:07:18,062	79	2
11:07:18,109	81	2
11:07:18,156	82	2
11:07:18,203	84	2
11:07:18,250	87	2
11:07:18,312	88	2
11:07:18,359	90	2
11:07:18,406	93	2
11:07:18,453	94	2
11:07:18,500	96	2
11:07:18,562	98	2
11:07:18,609	100	2
11:07:18,656	102	2
11:07:18,703	102	2
11:07:18,750	105	2
11:07:18,812	105	2
11:07:18,859	107	2
11:07:18,906	108	2
11:07:18,953	108	2
11:07:19,000	108	2
11:07:19,062	107	2
11:07:19,109	108	2
11:07:19,156	107	2
11:07:19,203	107	2
11:07:19,250	106	2
11:07:19,312	107	2
11:07:19,359	106	2
11:07:19,406	108	2
11:07:19,453	108	2
11:07:19,500	109	2
11:07:19,562	109	2
11:07:19,609	110	2
11:07:19,656	112	2
11:07:19,703	112	2
11:07:19,750	109	2
11:07:19,812	108	2
11:07:19,859	108	2
11:07:19,906	108	2
11:07:19,953	108	2
11:07:20,000	108	2
11:07:20,062	108	2
11:07:20,109	108	2
11:07:20,156	97	2
11:07:20,203	86	2
11:07:20,250	72	2
11:07:20,312	55	2
11:07:20,359	46	2
11:07:20,406	33	2
11:07:20,453	16	2
11:07:20,500	6	2
11:07:20,562	4	2
11:07:20,609	22	2
11:07:20,656	13	2
11:07:20,703	11	2
11:07:20,750	1	2
11:07:20,812	0	2
11:07:20,859	0	2
11:07:20,906	0	2
11:07:20,953	0	2
11:07:21,000	0	2
11:07:21,062	1	2
11:07:21,109	1	2
11:07:21,156	3	2
11:07:21,203	11	2
11:07:21,250	12	2
11:07:21,312	21	2
11:07:21,359	26	2
11:07:21,406	23	2
11:07:21,453	20	2
11:07:21,500	18	2
11:07:21,562	18	2
11:07:21,609	18	2
11:07:21,656	18	2
11:07:21,703	18	2
11:07:21,750	18	2
11:07:21,812	18	2
11:07:21,859	18	2
11:07:21,906	18	2
11:07:21,953	18	2
11:07:22,000	23	2
11:07:22,062	29	2
11:07:22,109	29	2
11:07:22,156	29	2
11:07:22,203	27	2
11:07:22,250	27	2
11:07:22,312	21	2
11:07:22,359	17	2
11:07:22,406	16	2
11:07:22,453	14	2
11:07:22,500	14	2
11:07:22,562	13	2
11:07:22,609	13	2
11:07:22,656	13	2
11:07:22,703	13	2
11:07:22,750	14	2
11:07:22,812	15	2
11:07:22,859	16	2
11:07:22,906	17	2
11:07:22,953	19	2
11:07:23,000	23	2
11:07:23,062	29	2
11:07:23,109	32	2
11:07:23,156	38	2
11:07:23,203	43	3
11:07:23,250	47	3
[/pre]
 
I assume pressures are in Column B

In C2 put 1

In C3 put =IF(B3>=40,IF(B2>=40,C2,C2+1),C2)

Copy C3 down
 
Assuming the code column in your example is the desired output

In C2, input 1.

In C3, input following formula:

=C2+AND(B3>=40,B2<40)


Granted, both of these are a formula solution. Let us know if you really need a VB solution.
 
Back
Top