PC Review


Reply
Thread Tools Rate Thread

Count number of times entries are made in a cell

 
 
MichaelRLanier@gmail.com
Guest
Posts: n/a
 
      10th Jul 2008
Is it possible to count the number of times a cell's content is
changed? For example, if an entry is made in cell A1, then later
deleted and re-entered, is there a macro that will tell me the cell
has had 2 entries total? Thanks for your help.
 
Reply With Quote
 
 
 
 
Jim Thomlinson
Guest
Posts: n/a
 
      10th Jul 2008
Right click the sheet tab you want this to work in and paste the following
code... It works on the cells in A1:A10. Change that to suit...

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim rngChanged As Range

Set rngChanged = Intersect(Target, Range("A1:A10")) 'Change range
If Not rngChanged Is Nothing Then
Application.EnableEvents = False
On Error Resume Next
For Each rng In rngChanged
rng.Offset(0, 1).Value = rng.Offset(0, 1).Value + 1
Next rng
On Error GoTo 0
Application.EnableEvents = True
End If
End Sub
--
HTH...

Jim Thomlinson


"(E-Mail Removed)" wrote:

> Is it possible to count the number of times a cell's content is
> changed? For example, if an entry is made in cell A1, then later
> deleted and re-entered, is there a macro that will tell me the cell
> has had 2 entries total? Thanks for your help.
>

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      10th Jul 2008
I might change this line...

rng.Offset(0, 1).Value = rng.Offset(0, 1).Value + 1

to this instead....

If rng.Offset(0, 1).Value <> "" Then
rng.Offset(0, 1).Value = rng.Offset(0, 1).Value + 1
End If

That way, deletions will not be counted (I think that is what the OP was
hinting at in his next-to-last sentence).

Rick


"Jim Thomlinson" <James_Thomlinson@owfg-Re-Move-This-.com> wrote in message
news:908629FE-1172-4B97-B67D-(E-Mail Removed)...
> Right click the sheet tab you want this to work in and paste the following
> code... It works on the cells in A1:A10. Change that to suit...
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> Dim rng As Range
> Dim rngChanged As Range
>
> Set rngChanged = Intersect(Target, Range("A1:A10")) 'Change range
> If Not rngChanged Is Nothing Then
> Application.EnableEvents = False
> On Error Resume Next
> For Each rng In rngChanged
> rng.Offset(0, 1).Value = rng.Offset(0, 1).Value + 1
> Next rng
> On Error GoTo 0
> Application.EnableEvents = True
> End If
> End Sub
> --
> HTH...
>
> Jim Thomlinson
>
>
> "(E-Mail Removed)" wrote:
>
>> Is it possible to count the number of times a cell's content is
>> changed? For example, if an entry is made in cell A1, then later
>> deleted and re-entered, is there a macro that will tell me the cell
>> has had 2 entries total? Thanks for your help.
>>


 
Reply With Quote
 
MichaelRLanier@gmail.com
Guest
Posts: n/a
 
      10th Jul 2008
Thanks Jim and Rick. Your help is much appreciated. I'll be trying
both approaches shortly.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I count the number of times a letter is used in a cell? =?Utf-8?B?anNyYXdsaW5ncw==?= Microsoft Excel Misc 5 28th Jun 2006 02:02 AM
count the number of cell entries after filtering =?Utf-8?B?R2F6emE=?= Microsoft Excel Misc 2 16th Mar 2006 01:31 PM
Count number of times a specific number is displayed in a cell ran =?Utf-8?B?c3Vicw==?= Microsoft Excel Worksheet Functions 1 27th Jun 2005 05:01 PM
Count the number of entries in a cell alavan Microsoft Excel Discussion 2 15th Apr 2004 12:28 AM
count number of entries in cell mkk Microsoft Excel Misc 12 20th Feb 2004 08:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:30 PM.