View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mcasteel[_11_] Mcasteel[_11_] is offline
external usenet poster
 
Posts: 1
Default VBA: New Idea to lookup record


I guess I didnt fully understand the Match function, and I find codin
it this way easier. Although I still cant get it to work.

With the following code I get the message "ssn not found" even when th
ssn entered is listed in the column.

Do I need to convert the InputCustSSN to an Integer?


Private Sub cmdSelectRecord_Click()

Dim Cell As Range
Dim found As Boolean

Dim lookUpRange As Range
Dim lookupsheet As Sheet1
Dim InputCustSSN As String
Dim rngActive As Range

n = ActiveCell.Value

Set rngActive = ActiveCell.Range("f27:f307")

InputCustSSN = txtCustSSN

found = False

If n < "" Then
For Each Cell In rngActive
If Cell.Value = InputCustSSN Then
found = True
Exit For
End If
Next Cell
End If

If Not found Then
MsgBox "SSN Not Found!"
Else
MsgBox "Customer SSN Found"
End If

End Sub


Its been a long day.
I promise I will take a refresher course on VBA as soon as the next on
is offered

--
Mcastee
-----------------------------------------------------------------------
Mcasteel's Profile: http://www.excelforum.com/member.php...fo&userid=1569
View this thread: http://www.excelforum.com/showthread.php?threadid=27258