View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Compare values in a column

But if you really need a macro - perhaps this will point you in the right
direction

Sub Test()
Dim rngData As Range
Dim i As Long

Set rngData = Worksheets("Sheet2").Range("A1:A5")

For i = 2 To rngData.Rows.Count
If rngData(i).Value - rngData(i - 1).Value < 1 Then
rngData.Cells(i).Interior.ColorIndex = 53
Else: rngData.Cells(i).Interior.ColorIndex = xlNone
End If
Next i

End Sub

"Tendresse" wrote:

I need help with a macro that checks that cells values in column A are
increasing by one increment. In Column A i put receipts numbers. I want to be
able to check if all receipts have been recorded. for example, if column A
looks like this:

A
1 100
2 101
3 103
4 104
5 105

All values are increasing by 1, except the value in cell A3 increased by 2.
Which means that Receipt Number 102 hasn't been recorded.
I want the macro to go through cells in column A, and once it detects a gap,
the cell fill colour (cell A3 in the above example) turns red.

I'm using Excel 2003.

Many thanks
Tendresse