Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA

Status
Not open for further replies.

scroce

MIS
Nov 30, 2000
780
US
Public Function MyFunc(DistNum)
If anyone can help, the see the short code below, i think it's pretty self explanatory.


Dim c As Variant
Dim LoopCounter As Variant
Dim Range3 As Range
Dim prTest As Variant

Set Range3 = Worksheets("Master 2001-02").Range("i1:i500")

For Each c In Worksheets("Master 2001-02").Range("b1:b500")
If c.Value = DistNum Then
MsgBox "found it"
Now that you've found it - look over 5 columns to the right in the same row for the value "pr" If it's there then MyFunc value = whatever is 6 columns over in the same row. If it's not there, then continue to the next match

End If
Next c


End Function

Hope someone can help. Thanks. How much more water would there be in the ocean if it weren't for sponges?
 
OK , if anyone cares here it is, i think:

Public Function MyFunc(DistNum)

Dim c As Variant
Dim LoopCounter As Variant
Dim Range3 As Range
Dim prTest As Variant

Set Range3 = Worksheets("Master 2001-02").Range("i1:i500")

For Each c In Worksheets("Master 2001-02").Range("b1:b500")

If c.Value = DistNum Then
'MsgBox "found it"
If InStr(c.Offset(0, 7), &quot;pr&quot;) <> 0 Then
' MsgBox &quot;here it is&quot;
MyFunc = c.Offset(0, 8)
End If
End If

Next c
How much more water would there be in the ocean if it weren't for sponges?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top