View Single Post
  #22   Report Post  
Posted to microsoft.public.excel.misc
Penny
 
Posts: n/a
Default Entering a range of numbers and searching same

That would make life too easy for me (and you!) It doesn't start in cell A1.
The beginning range of numbers starts in D2. Ending Range in E2. (I have a
header row). And R1 is where I have the field that I type in the document
number I'm searching for. This is what I have as of now:

Sub FindDoc()
Dim r As Range
Dim j, k, l As Long
Set r = Intersect(ActiveSheet.UsedRange, Columns("A:A"))
j = r.Rows.Count
k = --InputBox("Enter document number:")
Range("r1").Value = k
For l = 1 To j
If k = Cells(l, 1).Value Then
If k <= Cells(l, 2).Value Then
Cells(l, 3).Select
MsgBox ("Document Number " & k & " Client " & Cells(l, 3).Value)
Exit Sub
End If
End If
Next
MsgBox ("Document Number " & k & " not assigned")
End Sub

Thanks for being so patient with me. I'm learning but it's not quick enough
for me!

Penny

"Dave O" wrote:

Forgot to add that it's Ok if your data starts on a different row-
we'll just modify the code a bit, no worries.