I am having a major headache in trying to fix this! I only have this code for a textbox on my form
Then I have a module named GetDataMod which containsPrivate Sub Policy_Change() GetData 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.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
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
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
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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks