View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Sequence of numbers

Try the following code:

Sub AAA()
Dim OldValue As Variant
Dim Rng As Range
Dim Ndx As Long
OldValue = Range("A1").Value
For Each Rng In Range("A1:A10")
If Rng.Value < "" Then
If Rng.Value = OldValue Then
Ndx = Ndx + 1
Rng(1, 2).Value = Ndx
Else
OldValue = Rng.Value
Ndx = 1
Rng(1, 2).Value = Ndx
End If
End If
Next Rng
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"JohnUK" wrote in message
...
Hi,
I am looking for a way (through VBA) to enter a sequence of
numbers against
a column of dates. For example:
If column A had 10 cells with the same date, I then want column
B to
populate with numbers from 1 to 10.
If the next line had a single date, column B to show as a 1
(The dates will always be in order by the way)
If then there was a gap in column A to return a blank in column
B.
To show you what I mean in a little more detail:

Date column Sequence column

Mon 17 Jul 1
Mon 17 Jul 2
Mon 17 Jul 3
Tue 18 Jul 1
Wed 19 Jul 1
Thu 20 Jul 1
Thu 20 Jul 2
Thu 20 Jul 3
Thu 20 Jul 4
Fri 21 Jul 1
Sat 22 Jul 1

Mon 24 Jul 1
Mon 24 Jul 2

I hope I explained that well enough.
Many thanks for your help
John