Thread: Count dates
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Count dates

Looks like you want B1 to be a counter. Each time you change the date in A1,
B1 should increase by one. Use the following Worksheet macro:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("A1"), Target) Is Nothing Then
Application.EnableEvents = False
Range("B1").Value = Range("B1").Value + 1
Application.EnableEvents = True
End If
End Sub



Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

Now try entering material in cell A1. If you have any concerns, first try
it on a trial worksheet.

If you save the workbook, the macro will be saved with it.


To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm




--
Gary''s Student - gsnu200719


"poolgirl" wrote:

I need to keep track of how many dates the local swimming pool is open. When
I type in a date (for instance, May 15) in cell A1, I want cell B1 to tell me
that is day 1. When I enter the next date (May 16) in A1, I want B1 to tell
me it is day 2.
How can I keep track of how many days the pool is open?