Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Count number of times entries are made in a cell

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Count number of times entries are made in a cell

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


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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Count number of times entries are made in a cell

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" wrote in message
...
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


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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Count number of times entries are made in a cell

Thanks Jim and Rick. Your help is much appreciated. I'll be trying
both approaches shortly.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count the number of times a cell value is within a specific range Everett Excel Worksheet Functions 4 September 2nd 06 10:54 PM
How do I count the number of times a letter is used in a cell? jsrawlings Excel Discussion (Misc queries) 5 June 28th 06 02:02 AM
count the number of cell entries after filtering Gazza Excel Discussion (Misc queries) 2 March 16th 06 01:31 PM
How do I count the # of times an entry has been made in a month? Wayne New Users to Excel 13 December 28th 05 09:39 PM
Count number of times a specific number is displayed in a cell ran subs Excel Worksheet Functions 1 June 27th 05 05:01 PM


All times are GMT +1. The time now is 06:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"