Results 1 to 7 of 7

Thread: From function to sub

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2007
    Posts
    9

    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

  2. #2
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    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.

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2007
    Posts
    9

    Re: From function to sub

    Sorry.. are there any technical forum in here?

  4. #4
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: From function to sub

    Most of them are technical. Don't worry, a mod will move it once they see it.

  5. #5

    Thread Starter
    New Member
    Join Date
    Dec 2007
    Posts
    9

    Re: From function to sub

    allright..thx

  6. #6

    Thread Starter
    New Member
    Join Date
    Dec 2007
    Posts
    9

    Re: From function to sub

    well.. problem solved..

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,927

    Re: From function to sub

    As you appear to be working in Excel, I have moved this thread to our Office Development forum.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width