LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop a loop when certain data is found jsmith Excel Discussion (Misc queries) 3 June 2nd 08 10:12 PM
Loop to Filter, Name Sheets. If Blank, Exit Loop ryguy7272 Excel Programming 3 February 5th 08 03:41 PM
Loop through found value GregR Excel Programming 4 March 2nd 07 06:55 PM
Stop the loop when found. hfazal Excel Programming 1 February 16th 06 11:57 PM
End a loop if text is not found Ernesto[_3_] Excel Programming 2 August 19th 05 10:33 PM


All times are GMT +1. The time now is 04:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"