Position to excel row with entered value

58 Views Asked by At

I have names "ANDREW", "BLACK", "JONES", "JUNIPER", "NEWSHAM" and "SMITH" in the first vertical column of an Excel sheet. I wish to be able to enter a value in a separate excel cell and as I do so see the sheet immediately position itself to the next (alphabetically speaking) value in the first column. So if I key "J", then my sheet immediately positions itself with the topmost row starting "JONES". If I then follow the J with a "P" or for that matter a "U" it positions itself to "JUNIPER" being the next item alphabetically following my entry. The names are of course entered in alphabetic order. Your help please. I am happy with VBA programming.

Here is my code:

My alphabetic entries are located between A1 and A433.

I type a search value in cell L1, which triggers a worksheet change event:

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$L$1" Then
        Call MyMacro
    End If
End Sub

In addition, cell (1,9) has formula MATCH(L1,A2:A433)+1

When the subroutine MyMacro is executed:

Sub MyMacro()
ActiveWindow.ScrollRow = Worksheets(1).Cells(1, 9)
End Sub

it picks up the numerical MATCH value in cell 1,9 and positions to that row. This works sometimes but the entries in column A are a mixture of upper and lower case, and when entering values near the start of the table a Run Time Error - Type Mismatch appears. The cell 1,9 appears as "#N/A"

0

There are 0 best solutions below