Excel 2003 lookup macro needed

Microsoft Office 2003 small business edi...
November 3, 2010 at 01:43:21
Specs: Windows XP, 2.591 GHz / 2046 MB
I have a worksheet with col A containing hundreds of unique I.D. numbers. I need to write a macro with an input screen that I can type the I.D. into, and the macro should then take me to the correct line and move the cursor right to the first empty cell. Sounds simple but can't figure out how to do it! Can anybody help?

See More: Excel 2003 lookup macro needed

Report •

November 3, 2010 at 07:25:07
Option Explicit
Sub SelectID()
Dim myID
Dim findID As Range
Dim nxtCol As Integer
'Get ID from user
 myID = Application.InputBox("Enter ID Number", "Get ID")
'Quit if InputBox canceled
  If myID = False Then Exit Sub
'Find the ID in Column A
   With Columns("A")
    Set findID = .Find(myID, lookat:=xlWhole)
'If found, determine next empty cell in the row, select it and quit
      If Not findID Is Nothing Then
        nxtCol = Cells(findID.Row, "A").End(xlToLeft).Column + 1
        Cells(findID, nxtCol).Select
        Exit Sub
      End If
    End With
'If ID is not found, tell the user and loop back to InputBox
   MsgBox "ID not Found"
   GoTo getID
End Sub

Report •
Related Solutions

Ask Question