-
From function to sub
Hey..
I'm having troubles to get info from my function, and back again to my sub.. whats wrong?
Code:
Public Sub Member()
Dim MemberID As Integer
Dim Member As Integer
Do
MemberID = InputBox("write membernumber", "which member du you want?")
TFMember= TjeckMember(MemberID)
If TFMember= False Then
MsgBox ("member not valid. try again.")
End If
Loop Until Member = 1
End Sub
Public Function TjeckMember(MemberID As Integer) As Integer
Dim IDRange As Range
Dim ID As Variant
With ThisWorkbook.Worksheets("Members")
Set IDRange = Range(Range("A2"), Range("A2").End(xlDown))
For Each ID In IDRange
If ID = MemberID Then
TFMember= True
Exit For
Else
TFMember = False
End If
Next ID
End With
End Function
Really hope you can help...
Bjede
-
Re: From function to sub
First, this belongs in a technical forum.
Second, you aren't returning a value within your function. You have the function defined to return an Integer, but you never specify TO return said integer.
-
Re: From function to sub
Sorry.. are there any technical forum in here?
-
Re: From function to sub
Most of them are technical. Don't worry, a mod will move it once they see it.
-
Re: From function to sub
-
Re: From function to sub
-
Re: From function to sub
As you appear to be working in Excel, I have moved this thread to our Office Development forum.