ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   I need some checking done (https://www.excelbanter.com/excel-programming/348795-i-need-some-checking-done.html)

Andy

I need some checking done
 
Hello all i wrote a vb function and it doesnt seem to be working, help me out
and check it over

Here is the code:

Dim Amps As Range
Dim BrkL As Range
Dim CondMat As Variant
Dim CondTemp As Variant
Dim Conduit As Variant
Dim CondInsul As Variant
Dim CondTbl As Worksheet
Dim FeedEst As Worksheet
Dim Conductor As String

Public Function CdLkUp(BrkL, Amps, CondMat, CondTemp) As Variant

Set CondTbl = Worksheets("Conductor Tables")
Set FeedEst = Worksheets("Feeder Est.")

Select Case Amps
Case Is <= 20
CondLookup = CondTbl.Range("S43")

Select Case CondMat
Case Is = "Cu"
Select Case CondTemp
Case Is = 60
CdLkUp = Application.WorksheetFunction.VLookup(BrkL, _
CondTbl.Range("b10:e39"), 4, True)
Case Is = 75
CdLkUp = Application.WorksheetFunction.VLookup(BrkL, _
CondTbl.Range("c10:e39"), 3, True)
Case Is = 90
CdLkUp = Application.WorksheetFunction.VLookup(BrkL, _
CondTbl.Range("d10:e39"), 2, True)
End Select
Case Is = "Al"
Select Case CondTemp
Case Is = 60
CdLkUp = Application.WorksheetFunction.VLookup(BrkL, _
CondTbl.Range("f10:i39"), 4, True)
Case Is = 75
CdLkUp = Application.WorksheetFunction.VLookup(BrkL, _
CondTbl.Range("g10:i39"), 3, True)
Case Is = 90
CdLkUp = Application.WorksheetFunction.VLookup(BrkL, _
CondTbl.Range("h10:i39"), 2, True)
End Select
End Select
End Select
End Function

JE McGimpsey

I need some checking done
 
You may find someone who's willing to "check it over", but before
spending any time on it, it would be very helpful if you'd at least
indicate what the function should do, and what "doesn't seem to be
working" means (do you get a crash? the wrong result? no result? a
result error? a run-time error?)



In article ,
"Andy" wrote:

Hello all i wrote a vb function and it doesnt seem to be working, help me out
and check it over


Toppers

I need some checking done
 
Andy,
Appears to work OK EXCEPT if Amps20 when no VLOOKUP is executed.

Should CondLookup be CdLkUp?

If not, what is CondLookup ?

And, as per previous posting, what exactly is the problem?

"Andy" wrote:

Hello all i wrote a vb function and it doesnt seem to be working, help me out
and check it over

Here is the code:

Dim Amps As Range
Dim BrkL As Range
Dim CondMat As Variant
Dim CondTemp As Variant
Dim Conduit As Variant
Dim CondInsul As Variant
Dim CondTbl As Worksheet
Dim FeedEst As Worksheet
Dim Conductor As String

Public Function CdLkUp(BrkL, Amps, CondMat, CondTemp) As Variant

Set CondTbl = Worksheets("Conductor Tables")
Set FeedEst = Worksheets("Feeder Est.")

Select Case Amps
Case Is <= 20
CondLookup = CondTbl.Range("S43")

Select Case CondMat
Case Is = "Cu"
Select Case CondTemp
Case Is = 60
CdLkUp = Application.WorksheetFunction.VLookup(BrkL, _
CondTbl.Range("b10:e39"), 4, True)
Case Is = 75
CdLkUp = Application.WorksheetFunction.VLookup(BrkL, _
CondTbl.Range("c10:e39"), 3, True)
Case Is = 90
CdLkUp = Application.WorksheetFunction.VLookup(BrkL, _
CondTbl.Range("d10:e39"), 2, True)
End Select
Case Is = "Al"
Select Case CondTemp
Case Is = 60
CdLkUp = Application.WorksheetFunction.VLookup(BrkL, _
CondTbl.Range("f10:i39"), 4, True)
Case Is = 75
CdLkUp = Application.WorksheetFunction.VLookup(BrkL, _
CondTbl.Range("g10:i39"), 3, True)
Case Is = 90
CdLkUp = Application.WorksheetFunction.VLookup(BrkL, _
CondTbl.Range("h10:i39"), 2, True)
End Select
End Select
End Select
End Function



All times are GMT +1. The time now is 03:32 AM.

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