+ Reply to Thread
Results 1 to 3 of 3

Thread: Sub, Function, or Property not defined (Error 35)

  1. #1
    Registered User
    Join Date
    08-03-2011
    Location
    Norwich
    MS-Off Ver
    Excel 2003
    Posts
    12

    Sub, Function, or Property not defined (Error 35)

    I am having a major headache in trying to fix this! I only have this code for a textbox on my form

    Private Sub Policy_Change()
    GetData
    End Sub
    Then I have a module named GetDataMod which contains

    Private Sub GetData()
    
    Dim r As Long
    Sheets(3).Activate
    
    If IsNumeric(Policy.Text) Then
        r = CLng(Policy.Text)
        
    Else
        'ClearData
        MsgBox "Not Found"
        Exit Sub
        
    End If
    
    If r > 1 And r <= LastRow Then
        Surname.Text = FormatNumber(Cells(r, 3), 0)
    
        
        
    ElseIf r = 1 Then
        'ClearData
    
    Else
        'ClearData
        MsgBox "No Policy Number"
        
    End If
    
    End Sub
    The idea being that when you change the input of the textbox then the data is grabbed from sheet3 and loaded into the userform.

    However as soon as I enter the start of a policy number in the box I get the compile error: Sub Function or Property not defined

    Any ideas what I am missing?

    Excel 2010
    Last edited by TMShucks; 01-12-2012 at 09:51 AM. Reason: code tags amende

  2. #2
    Valued Forum Contributor tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    USA
    MS-Off Ver
    Excel 2003 - 2007
    Posts
    2,352

    Re: Sub, Function, or Property not defined (Error 35)

    herghost,

    The problem is that the userform code is calling a Private sub that is in a different module. You'll either have to make the Private GetData sub part of the userform code, or take off the Private keyword.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Valued Forum Contributor tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    USA
    MS-Off Ver
    Excel 2003 - 2007
    Posts
    2,352

    Re: Sub, Function, or Property not defined (Error 35)

    Alternatively you could explicitly let the compiler know where the Private sub GetData is:
    Private Sub Policy_Change()
        GetDataMod.GetData
    End Sub
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0