Count when cell has changed

Jer-XL-emy

Board Regular
Joined
Aug 27, 2007
Messages
60
Hello, I bow down to the genuises that reside here.
My Question is: How can I have a cell count the number of times another cell changes.
I have a macro found on this forum that does work when I manually change the cell, but will not work when the cell changes automatically.

Here is what I have

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Column = 22 Then Target.Offset(0, -5).Value = Target.Offset(0, -5).Value + 1
If Target.Count > 1 Then Exit Sub
If Target.Column = 23 Then Target.Offset(0, -5).Text = Target.Offset(0, -5).Text + 1
End Sub
(modified for my purposes)

This is a macro written from a longtime poster here (I cannot find where I found it so I cannot give him the credit he deserves)

Again, it works when I change the cell manually, but there is a formula behind it and I need it to work when the cell changes on the surface

I am assuming it has something to do with the .value - but not sure

I thank you in advance
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Welcome to the Board!

You need to use a Worksheet_Calculate event for that. Unfortunately it doesn't support the Target argument, so you need to specify the cell you want to count.

I.E.

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Calculate()
    Range("B1").Value = Range("B1").Value + 1
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Hope that helps,

Smitty
 
Upvote 0
Hi and welcome to the Board!!

If it's changed by a formula, then it means it is probably changed when some other cell(s) are changed manually. If so, target your Change event on those cell(s). What is the formula?

lenze
 
Upvote 0
Wow, that a fast response - Thanks for that. I have use excel for many years but now just learning all I can with VBA (Just realized the signifcant power of excel with VBA) - I think it will soon run every asset of my life : )

Actually sorry its not a formula its a feed - (DDE i think or its newer counter part)

And its for a column (well too, but I can figure that out :p )

And again thanks for your quick responses - and thanx for having me

I am going to give some of these a try
 
Upvote 0
Actually sorry its not a formula its a feed - (DDE i think or its newer counter part)

How are you refreshing the feed?

You may be able to incorporate that.

Smitty
 
Upvote 0
Perhaps this :-

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range, cell As Range
Set rng = Intersect(Target, [V:W])
If Not rng Is Nothing Then
    Application.EnableEvents = False
    For Each cell In rng
        cell(1, -4) = cell(1, -4) + 1
    Next
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0
It refreshes all on its own (how I'm not sure) - It is a DDE feed, I'd did get a verification on that
 
Upvote 0
Still a no go Boller, It does the same as my previous (assuming I did it right and its not using the previous Macro, which I did delete) which is works well when I go into the cell, but when the cell changes it does nothing.

Hmmm...do you think its even possible?
Is there some way to access the front information and not the background information (sorry my Excel jargon is not upto par yet)? Because when you copy/paste special - I thought the value was the visable info in the cell and formula was the hidden info, but I dont think that is right.
 
Upvote 0
Hhhhhhmmmm...It would have to be possible, because I have formulas that run off of the shown value, and conditional formating can also run off of what is shown....maybe I should use some kind of linked cells or cells that are equal to that cell and have the macro run off those cell instead - probably i will just have the same problem...what do you guys think?
 
Upvote 0

Forum statistics

Threads
1,215,545
Messages
6,125,450
Members
449,227
Latest member
Gina V

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