Loops in a function
I hope someone can figure out what i am doing wrong
here is the code, then the explanation at the end
_____________________________________
Dim WS As Range
Dim Alamps As Variant
Dim Alamps2 As Variant
Dim Cuamps As Variant
Dim A As Worksheet
Dim B As Worksheet
Dim intCounter As Integer
Dim Temp As Range
Dim TAl As Integer
Dim TCu As Integer
Function NOAMPS(WS)
Set A = Worksheets("ALL PRICES")
Set Temp = Worksheets("ALL PRICES").Range("C17")
Select Case Temp
Case Is = 60
TAl = 1
TCu = 4
Case Is = 75
TAl = 2
TCu = 5
Case Is = 90
TAl = 3
TCu = 6
End Select
Cuamps = Application.WorksheetFunction.vlookup(WS, A.Range("G7:M36"), 6,
False)
Alamps = Application.WorksheetFunction.vlookup(WS, A.Range("G7:M36"), 3,
False)
If Alamps = Cuamps Then
NOAMPS = Application.WorksheetFunction.vlookup(Alamps,
A.Range("F7:M36"), 8, False)
Else
intCounter = 0
Do
intCounter = intCounter + 1
Alamps2 = Application.WorksheetFunction.Index(A.Range("F7:F3 6"), _
Application.WorksheetFunction.Match(Application.Wo rksheetFunction.vlookup(WS,
A.Range("F7:M36"), 3, False), _
A.Range("G7:G36")) + 1)
NOAMPS = Application.WorksheetFunction.vlookup(Alamps2,
A.Range("F7:M36"), 8, False)
Loop Until Alamps2 = Cuamps
End If
End Function
____________________________
The function of this code is to be able to look up a wire size base on the
wire size and composition. So when it was looking up a the wire size i want
it to compare the amp rating for the wire to the other. The wire selection is
then based apon if the wire is either greater than or equal to the wire size
that it is being compared to..
Thanks again guys
Andy
|