S

#### scott

shows my Data Range of A2:B5. In LISTING 2, I'm trying make the sub

InsertMatch() loop through each cell in Column A until it finds a cell equal

to the new integer value. If a Column A cell is equal to the new integer

value, I need to insert it in the Column B cell that is 1 cell to the right

of the "matched" cell in Column A.

If no match is found, then just insert the new integer value into cell B2.

The Data Range of A2:B5 will always be growing because my form inserts a new

row at B before inserting a new value.

My InsertMatch sub is giving me a "Over Flow error". Can someone help me

figure out why my sub InsertMatch is giving this error?

So if this works, if a new integer value of 50 would be entered, it would be

inserted into cell B3.

Any help would be appreciated.

LISTING 1:

ColA ColB

45

50

60 60

75

LISTING 2:

Sub InsertMatch(iValue As Integer)

Dim c As Range, i As Integer

Set c = ActiveSheet.Range("B2")

iLastRow = getColumnLastRow("A")

For i = 2 To iLastRow

i = c.Row

If c.Offset(0, -1).Value = iValue Then

c.Value = iValue

Else

ActiveSheet.Range("B2") = iValue

End If

'set c to the next cell down

Set c = c.Offset(1, 0)

Next

End Sub

Function getColumnLastRow(sCol As String)

getColumnLastRow = ActiveSheet.Cells(Rows.Count, sCol).End(xlUp).Row

End Function