Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Loop thru xx No. of sheets until the four strValue combo's are found
I'm trying to modify some archived code to lookup four inputs and return a fifth, which is the price.
This works fine on a single sheet but I may have to take the bushel basket full of strValue's and look for that combination across 4,5 maybe 6 sheets. The "For Each rngCell In Range("A1:A" & lngLstRow)" of sheet Data1, Data2, Data3etc. has me stumped. I haven't gotten this far yet, but with that many inputs, I probably want to list the inputs and the price when found. I'll be working on that in the meantime. Thanks. Howard Option Explicit Sub Lookup_Four_Return_Fifth() Dim rngCell As Range Dim lngLstRow As Long Dim strValue(1 To 4) As String Dim intVStore(1 To 50) As Integer Dim intValVar As Integer lngLstRow = ActiveSheet.UsedRange.Rows.Count strValue(1) = InputBox("Input DA:", "DA") 'Col A strValue(2) = InputBox("Input AA:", "AA") 'Col B strValue(3) = InputBox("Input P:", "P") 'Col C strValue(4) = InputBox("Input HAULER:", "HAULER") 'Col D intValVar = 1 For Each rngCell In Range("A1:A" & lngLstRow) If rngCell.Value = strValue(1) And _ rngCell.Offset(0, 1).Value = strValue(2) And _ rngCell.Offset(0, 2).Value = strValue(3) And _ rngCell.Offset(0, 3).Value = strValue(4) Then intVStore(intValVar) = rngCell.Offset(0, 4).Value ' COL E intValVar = intValVar + 1 Else End If Next MsgBox ("The Priced is: " & WorksheetFunction.Max(intVStore())) End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Stop a loop when certain data is found | Excel Discussion (Misc queries) | |||
Loop to Filter, Name Sheets. If Blank, Exit Loop | Excel Programming | |||
Loop through found value | Excel Programming | |||
Stop the loop when found. | Excel Programming | |||
End a loop if text is not found | Excel Programming |