Count Change from "C" to "B"

Cell A1 can = "C" or "B" or "P" or "S"

Each Time Cell A1 changes from "C" to "B" I need to increment the value in B1 by 1.

If A1 changes to P or S or from B to C then cell B1 should do nothing. It is only the action of changing from "C" to "B" that I need to count.
IT SSMAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TEKDesignCEO/Consultant/OwnerCommented:
What software or programming language are you working on?
0
IT SSMAuthor Commented:
Sorry I am working on Excel 2013, VBA
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Try this....

Right click on the Sheet Tab --> View Code --> Paste the code given below into the opened code window --> Close the VBA Editor --> Save your workbook as Excel Macro-Enabled Workbook.
Dim oVal
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(0, 0) = "A1" Then
   If LCase(oVal) = "c" And LCase(Target) = "b" Then
      Target.Offset(0, 1) = Target.Offset(0, 1) + 1
   End If
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address(0, 0) = "A1" Then
   oVal = Target
End If
End Sub

Open in new window

0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

IT SSMAuthor Commented:
Hi sktneer
I have tested the code but it doesn't appear to work. I have attached the spreadsheet.
Test1.xlsm
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
That is because you placed the code on ThisWorkbook Module not on Sheet1 Module.
I have corrected it and check whether it works for you or not.
Test1.xlsm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IT SSMAuthor Commented:
Very quick response and correct function thanks Sktneer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.