ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Lookup (https://www.excelbanter.com/excel-programming/315619-lookup.html)

John Keturi

Lookup
 
The below code looks up a user value and returns it as c. Another cell on
the worksheet then uses this value and using the VLOOKUP function, returns
the lookup value in column 2. There are numerous instances where the lookup
value is the same, ie 1234. Although the lookup value may be the same
(inventory #), the date columns may be different. However, it seems to just
keep returning the date from the first instance of 1234 it finds. Is there a
way to force it to return the date for EACH instance of 1234 it finds. Any
suggestions?

Sub Lookup()
Dim myValue As Range
Set myValue = Range("F9")
With Worksheets("Data").Range("a1:a10000")
Set c = .Find(myValue, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
myValue(7).Value = c
lgHook = SetWindowsHookEx(&H5, AddressOf WinProc, 0,
GetCurrentThreadId)
Y = MsgBox("Do you want to find Next " & myValue, vbYesNo, "Find
Next?")
If Y = vbNo Then Exit Do
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
End Sub




All times are GMT +1. The time now is 12:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com