Compile error method or data member not found vba

I have been using this excel program for several months without issues. suddenly a couple days ago it started to throw this error. On sheet named "Input" I will double click a cell in column "A" ...

I have been using this excel program for several months without issues. suddenly a couple days ago it started to throw this error. On sheet named «Input» I will double click a cell in column «A» which will create a drop down box that will fill with data from the «Data» sheet. I start typing and then I select the data to add to the cell. Now when I click the cell and get an error message «Compile Error — Method or data member not found». Here is my block of code and the error is showing near the bottom highlighting «Me.TempCombo.Activate».

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Dim str As String
    Dim cboTemp As OLEObject
    Dim ws As Worksheet
    Set ws = ActiveSheet

    If Target.Column = 1 And Target.Row > 12 And Target.Row <> HRRow And Target.Row <> HRRow - 1 Then

        lRow = Sheets("Data").Range("A65536").End(xlUp).Row
        Set cboTemp = ws.OLEObjects("TempCombo")
          On Error Resume Next

          With cboTemp
          'clear and hide the combo box
            .ListFillRange = ""
            .LinkedCell = ""
            .Visible = False
          End With
        On Error GoTo errHandler
          'If Target.Validation.Type = 3 Then
            'if the cell contains a data validation list
            Cancel = True
            Application.EnableEvents = False
            'get the data validation formula
            'str = Target.Validation.Formula1
            'str = Right(str, Len(str) - 1)
            str = "=Data!A2:A" & lRow

            With cboTemp
              'show the combobox with the list
              .Visible = True
              .Left = Target.Left
              .Top = Target.Top
              .Width = Target.Width + 5
              .Height = Target.Height + 5
              .ListFillRange = str
              .LinkedCell = Target.Address
            End With
            'cboTemp.Activate
            Me.TempCombo.Activate
            'open the drop down list automatically
            Me.TempCombo.DropDown

      End If

errHandler:
      Application.EnableEvents = True
      Exit Sub
End Sub

I tried several things and for the life of me I cannot figure out what changed.
Any help will be appreciated. Thank you.

Kritner's user avatar

Kritner

13.4k10 gold badges50 silver badges72 bronze badges

asked Dec 10, 2014 at 14:26

Scott's user avatar

2

I ran into the same error and was able to solve it as Rory suggested. I searched my machine for *.exd files and found a few. The issue was solved for me after removing C:Users<username>AppDataLocalTempExcel8.0MSForms.exd…the others seemed to be unrelated to the ActiveX controls in Excel.

answered Dec 29, 2014 at 21:13

Tom's user avatar

Looks like the code came from an example like this: http://www.contextures.com/xlDataVal10.html

except your code has commented out the line which activates the cboTemp combobox. Your code is attempting to access the TempCombo attribute of the worksheet (which I don’t think exists). Uncomment 'cboTemp.Activate on the line above the highlighted error line.

answered Dec 10, 2014 at 14:39

Lefty's user avatar

LeftyLefty

4263 silver badges10 bronze badges

I had the same problem, my code broke this morning. Fortunately, I recalled that I ran Windows Update this weekend. I performend a system restore (earliest available restore point was 8th of december), and now the problem is gone.

I never did understand the panicy server guys who were always making backups and spending a whole lot of time testing before/after system updates, in all my years I never experienced any problems. Now I sure figured out what they were talking about. Lesson learnt. I’ll try running win update again in a few months, hopefully MS has solved the problem by then.

Best of luck

answered Dec 15, 2014 at 19:18

Fossie's user avatar

1

  • Remove From My Forums
  • Question

  • Getting compile error for following line of code:’

        Set txt1 = Me.Controls.Add(«VB.TextBox», «txt1»)

    Using VBA 7.1

    Any idea as to why?

    • Moved by

      Thursday, September 15, 2016 11:11 PM
      Move from VBA

Answers

  • Add is a method of the Controls collection on a userform in for example Word or Excel. It does not apply to Access.

    Access has the CreateControl method. This only works if the form is in Design view or in Layout view, not if the form is in Form view. So if you open the form in Form view, the code will cause an error.

    Example:

        Set txt1 = CreateControl(FormName:=»Form1″, ControlType:=acTextBox, _
            Section:=acDetail, Left:=1440, Top:=1440, Width:=1440, Height:=240)


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Proposed as answer by
      Chenchen Li
      Saturday, September 17, 2016 4:28 AM
    • Marked as answer by
      Chenchen Li
      Tuesday, September 20, 2016 7:43 AM

Permalink

Cannot retrieve contributors at this time

title keywords f1_keywords ms.prod ms.assetid ms.date ms.localizationpriority

Method or data member not found (Error 461)

vblr6.chm1000461

vblr6.chm1000461

office

10733744-502f-06b3-f0c6-5f039d017be4

06/08/2017

medium

The collection, object, or user-defined type doesn’t contain the referenced member. This error has the following causes and solutions:

  • You misspelled the object or member name. Check the spelling of the names and check the Type statement or the object documentation to determine what the members are and the proper spelling of the object or member names.

  • You specified a collection index that’s out of range. Check the Count property to determine whether a collection member exists. Note that collection indexes begin at 1 rather than zero, so the Count property returns the highest possible index number.

For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).

[!includeSupport and feedback]

 

Andrey_Iv

Пользователь

Сообщений: 2
Регистрация: 25.01.2018

Добрый день!
Подскажите, пожалуйста,  при создании формы, которая будет вписывать в таблицу строки по порядку возникает ошибка. Файл прилагаю, если не сложно просьба объяснить в чем ошибка.
Спасибо.

 

Sanja

Пользователь

Сообщений: 14837
Регистрация: 10.01.2013

В Вашей форме отсутствует Me.TextBox12  

Прикрепленные файлы

  • Ошибка.jpg (36.57 КБ)

Изменено: Sanja25.01.2018 18:08:14

Согласие есть продукт при полном непротивлении сторон.

 

Andrey_Iv

Пользователь

Сообщений: 2
Регистрация: 25.01.2018

Спасибо! Нашел исправил, а подскажите, пожалуйста, можно ли в некоторых ячейках добавить выпадающий список в форме?
Благодарю за ответ!

 

Kcuxa_xa

Пользователь

Сообщений: 68
Регистрация: 30.12.2018

Добрый вечер. У меня в макросе аналогичная ошибка при закрытии формы. Причем на одном листе (ОСАГО) форма работает как надо,  другом листе (АКБ) такой же код выдает ошибку. Все пересмотрела, не могу найти ошибки( Помогите пожалуйста, что тут может быть не так?

 

Ігор Гончаренко

Пользователь

Сообщений: 13254
Регистрация: 01.01.1970

#5

20.01.2019 21:48:06

Цитата
Andrey_Iv написал:
можно ли в некоторых ячейках добавить выпадающий список

зачем ограничивать себя некоторыми? — можете добавить во все

Программисты — это люди, решающие проблемы, о существовании которых Вы не подозревали, методами, которых Вы не понимаете!

 

Hugo

Пользователь

Сообщений: 23134
Регистрация: 22.12.2012

Kcuxa_xa,  у меня обе формы закрываются без проблем, ошибок нет.
На какой строке ошибка у Вас?

 

Юрий М

Модератор

Сообщений: 60383
Регистрация: 14.09.2012

Контакты см. в профиле

#7

20.01.2019 22:38:49

Цитата
vikttur написал:
название темы очень общее

Есть варианты?

 

Hugo

Пользователь

Сообщений: 23134
Регистрация: 22.12.2012

Юр, думаю раз за год ответа не получили, то уже и не получим :(

 

Kcuxa_xa

Пользователь

Сообщений: 68
Регистрация: 30.12.2018

Серьезно? Странно очень. А у меня выдает такую ошибку на строчке akb.Hide

Прикрепленные файлы

  • Ошибка.jpg (30.03 КБ)

Изменено: Kcuxa_xa20.01.2019 22:45:25

 

Юрий М

Модератор

Сообщений: 60383
Регистрация: 14.09.2012

Контакты см. в профиле

#10

20.01.2019 22:54:26

Цитата
Hugo написал:
за год ответа не получили

Я и не посмотрел на год ))
Но давайте для удобства поиска что-нибудь придумаем.

 

RAN

Пользователь

Сообщений: 7081
Регистрация: 21.12.2012

#11

20.01.2019 22:58:38

Код
Me.Hide

Ну не нравится форме обращаться к себе в третьем лице.  :D

 

ocet p

Пользователь

Сообщений: 437
Регистрация: 24.03.2018

#12

20.01.2019 22:58:47

Цитата
Hugo написал:
выдает такую ошибку на строчке akb.Hide

akb.Value (TextBox ?) <> akb.Hide (UserForm)
:)

 

doober

Пользователь

Сообщений: 2139
Регистрация: 09.04.2013

#13

20.01.2019 22:59:24

Цитата
Kcuxa_xa написал:
Странно очень.

Ничего странного нет.
У Вас имя формы и текстбокса одинаковые.
Замените akb.Hide на me.Hide

<#0>

 

Hugo

Пользователь

Сообщений: 23134
Регистрация: 22.12.2012

#14

20.01.2019 23:00:01

Kcuxa_xa, а я ничего не заполнял, не было такого в условии задачи :)
Тут у меня тоже ошибка, можно сделать проще — заменить эту строку на

Код
Me.Hide

Ошибка потому, что есть форма akb, а есть и текстбокс akb… Я поменял имя текстбоксу (ну и в коде) — взлетело.

Изменено: Hugo20.01.2019 23:04:37

 

Kcuxa_xa

Пользователь

Сообщений: 68
Регистрация: 30.12.2018

Спасибо всем огромное))))) получилось :D  

 

Hugo

Пользователь

Сообщений: 23134
Регистрация: 22.12.2012

#16

20.01.2019 23:05:01

Написал выше почему была ошибка.
P.S. Как оказывается не я первый написал, тормозит обновление :)

Изменено: Hugo20.01.2019 23:07:01

  1. 08-17-2017, 10:51 AM


    #1

    jtsev13 is offline


    Registered User


    Compile Error: Method or data member not found

    I am having an issue where an error window pops up saying «Compile error: Method or data member not found». This happens occasionally when I open a specific excel file, but strangely not every time. Everything in the spreadsheet seems to work fine, I was just wondering if anyone knows what my issue is and why this message pops up from time to time.

    Here is the VBA code:


  2. 08-17-2017, 04:26 PM


    #2

    Re: Compile Error: Method or data member not found

    What line of code is highlighted when you get the error?

    Jeff
    | | |?| |?| |?| |?| | |:| | |?| |?|
    Read the rules
    Use code tags to [code]enclose your code![/code]


  3. 08-18-2017, 07:16 AM


    #3

    jtsev13 is offline


    Registered User


    Re: Compile Error: Method or data member not found

    The very first line, «Private Sub ComboBox1_Change()».

    I’m very new to VBA and really not totally sure what I’m doing yet. This is a code I found online and it’s been serving its purpose so far, but the pop-up message can get annoying. Any suggestions would be greatly appreciated!


  4. 08-24-2017, 07:43 AM


    #4

    jtsev13 is offline


    Registered User


    Re: Compile Error: Method or data member not found

    Here is the link to the thread where I originally got the code.

    https://www.excelforum.com/excel-pro…-combobox.html

    Like I said, it seems to work fine, so I’m not really sure why I keep getting this error message. The spreadsheet is meant to be interactive as a quick lookup tool for different set points and tooling of machinery depending on the production line and which product is running. The code was used to make my second combobox drop-down list dependent on the selected value of the first combobox.

    It worked but I have been getting this error pop-up every time I open the document. Does anybody have any idea how to make it stop? The error message highlights the first line of the code.


  5. 08-24-2017, 09:02 AM


    #5

    Re: Compile Error: Method or data member not found

    It doesn’t make sense that you get a compile error when opening the file, but then the code runs correctly. Can you attach your file?


  6. 08-24-2017, 03:50 PM


    #6

    jtsev13 is offline


    Registered User


    Re: Compile Error: Method or data member not found

    Here is the file. The compile error usually pops up, put strangely not every single time I open the spreadsheet, just most of the time.


  7. 08-24-2017, 08:54 PM


    #7

    Re: Compile Error: Method or data member not found

    I opened your file about 8 times and could not reproduce the error, although I did get your code to execute just fine. I am using Excel 2016 on Windows 10.

    There are two strange things about your problem. First, there is no reason that VBA should be trying to compile that code when you open the file. You have no code in the ThisWorkbook module, so there would no attempt to execute anything until you either make a selection on the ref sheet, or update combobox1. VBA won’t compile code unless you ask it to, or execute something. And as you said, all that code runs fine. Second, the only reason a Sub statement would fail to compile is if it had invalid syntax. «Method or data member not found» does not make sense for a Sub statement.

    I’m sorry but it’s a dead end for me since I can’t make it happen. Maybe someone else recognizes this kind of problem.


  8. 08-24-2017, 09:27 PM


    #8

    Re: Compile Error: Method or data member not found

    The only time that I could reproduce the error is when sheets Lookup isn’t the active sheet when the file is saved and closed.

    This seems to be a solution.
    In ThisWorkbook.

    and your code like this.

    Avoid using Select, Selection and Activate in your code. Use With … End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.


  9. 08-25-2017, 08:02 AM


    #9

    jtsev13 is offline


    Registered User


    Re: Compile Error: Method or data member not found

    @6StringJazzer, I thought that it seemed strange that I was getting an error on a working code. And like I said, it doesn’t even happen every time which I thought to be probably the strangest thing about my problem. I don’t change anything before closing the document, but for whatever reason the error continues to pop up almost every other time I open the document.

    @bakerman2, Thanks for your suggestions, but it doesn’t seem to matter even if I have «Lookup» as my active sheet when I save and close the file. When I go to open it again, I will still get the error every other time I open the file. I even tried adding your code to ThisWorkbook and I still get the error.

    I am using Excel 2016 on Windows 7. I have attached images of what the error looks like when it pops up if that helps at all.

    Thanks for your help!


  10. 08-25-2017, 08:32 AM


    #10

    Re: Compile Error: Method or data member not found

    As I already said I can only reproduce the error when Lookup isn’t the active sheet on closing. Otherwise all works just fine.
    Seems you didn’t try the second code when I see your screenshot.
    Which References do you have activated ?


  11. 08-25-2017, 09:28 AM


    #11

    Re: Compile Error: Method or data member not found

    Thank you for the screenshot. This is different than I thought. The Sub line is highlighted, meaning that is the line that VBA is attempting to execute, but that is not where the compile error occurs. VBA attempts to compile this code when it starts to run it, and the error is at the name highlighted in blue. This error means that it cannot find a control named ComboBox2. This does not help solve your problem though because:

    1. ComboBox2 is definitely on the sheet
    2. This code shouldn’t even be running just from opening the file

    I was able to reproduce the error using bakerman2‘s input that it occurs if Lookup is not the active sheet when saved and closed. I have a simple change that worked for me, but frankly I was shooting in the dark and do not know why this works. My suspicion is that there is something buggy in Excel that causes the code to execute before the controls are fully loaded on startup, and adding this line gives it time to catch up. But that still does not explain why this code is running in the first place.

    This fix worked for me:


  12. 08-25-2017, 10:17 AM


    #12

    jtsev13 is offline


    Registered User


    Re: Compile Error: Method or data member not found

    Thank you both for your suggestions. Unfortunately I am still getting the error after adding DoEvents to the beginning of the code. I even tried changing all of the «Me.ComboBox» to «Sheet1.Combobox» like bakerman2 suggested, but still no luck.

    Thank you 6StringJazzer for explaining everything. Like I said I’m fairly new to VBA so any explanations as to how it works are appreciated.

    I suppose I can just use Data Validation to get the same drop-down lists, I just hate how small the font is. At least with the ComboBoxes you can change the formatting a bit. Anyway, thanks again for all your help and suggestions.


  13. 08-25-2017, 12:08 PM


    #13

    Re: Compile Error: Method or data member not found

    My best guess it’s an xml-thing because on closing the workbook XL seems to forget there’s an ActiveX-object called ComboBox2 is present.


  14. 08-25-2017, 02:06 PM


    #14

    jtsev13 is offline


    Registered User


    Re: Compile Error: Method or data member not found

    Well, I’m not really sure why this solved my problem, but I just renamed each ComboBox to a custom name and changed the code to reflect my custom names and now this error hasn’t popped up once. I don’t see why that fixed it considering they were named ComboBox1 and ComboBox2 by default, so changing the name shouldn’t have really made a difference. But anyway, thank you both for your help, and thank you for your last post bakerman2. It’s when you said, «XL seems to forget there’s an ActiveX-object called ComboBox2», that gave me the idea to try changing the names.

    Problem solved!


  15. 07-24-2018, 04:07 AM


    #15

    bongo_bg is offline


    Registered User


    Re: Compile Error: Method or data member not found

    Hello,

    A bit of pretty old topic but I was having those weird issues as well on 2 diferent documents with combo boxes. All the same, all working but during opening I received that error.

    I did tried the suggestion from 6StringJazzer with the ‘DoEvents’ and that fixxed it for me. So thank you!


  • #2

The Combox1_Change routine is an event assigned to the combo box. It happens automatically when a change is made to the selections of the combo box. You can’t call the routine the way you are attempting to do (hence the «method» error). Whatever code you have in the combo box_Change routine will occur when you select something from the combo box. If you are assigning a value to your combo box with the «S» variable, then the Change code should be automatically activated, but not until you close the box, or make some other selection change.

  • #3

Hiya,

The same code does work for a different userform however… combobox2_change will force the event to run

  • #4

A lot of this depends on where you are putting the code, etc. It’s hard to tell what you are trying to make happen with this, that wouldn’t happen anyway with the normal change event (without having to call the event). But, if you put code in ComboBox1’s Change event that calls Comobox2’s change code, then yes, it will work (I’m not why you would want to do that)

For example: the code below calls a userform with 2 comboboxes, and puts the number 10 in the window of the 2nd combobox

That change, triggers combobox2 to call the Change code for combobox1 and puts «hello» in the cell A1. Those codes are within the userform code module. But I can’t just call the change event from the first routine which is on my sheet module. But still, it’s a very round about way to accomplish this. Can you explain why you need it to do it this way? I’m having a hard time imagining the use of «combo boxes» for this, but of course I don’t have the whole picture.

Code:

Private Sub CommandButton1_Click()
S = 10
UserForm1.ComboBox2 = S

UserForm1.Show
End Sub
 
Private Sub ComboBox1_Change()
Range("A1") = "hello"
End Sub
 
Private Sub ComboBox2_Change()
Call ComboBox1_Change
End Sub

  • #5

Code:

UserForm5.Show
UserForm5.ComboBox2.Value = S: UserForm5.ComboBox2_Change
End Sub

If Userform5 is modal. The last (double) line of code will not run until UF5 is dismissed by the user.

The sequence will be

UserForm5.Show
‘[ user dismisses UF ]

UserForm5.ComboBox2.Value = S
‘[ a new instance of UF5 is loaded and the combobox value is changed]
‘[ note this new instance of UF5 is loaded but NOT shown, therefore invisible]

UserForm5.ComboBox2_Change
‘[ the event code is run]

End Sub
‘[ the (invisible) userform is loaded, if exicutuion passes back to some other VB routine, it will remain loaded, but not visible]

Last edited: Mar 10, 2010

  • #6

Hiya,

Thanks guys, but still not there :s

hilyete — i’ll put a bit more background together.

The code is triggered on doubleclick of a listbox within a userform called userform3:

Rich (BB code):

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
If ListBox1.ListIndex = -1 Then Exit Sub
If ListBox1.ListCount = 1 Then Exit Sub
Dim S As Integer
S = ListBox1.List(ListBox1.ListIndex, 0)
If ComboBox1.Value = "Projects" Then GoTo 20
UserForm3.Hide
Load UserForm4
UserForm4.ComboBox3.Value = S: UserForm4.ComboBox3_Change
UserForm4.Show
Exit Sub
20
UserForm3.Hide
Load UserForm5
UserForm5.Show
UserForm5.ComboBox2.Value = S
UserForm5.ComboBox2_Change

End Sub

That’s my complete code. Mike — i’ve swapped the code lines around but VBA still errors out giving me a «Method or data member not found» error message on the bold code above.

As i say, the only difference (and the code above for userform4 works perfectly) seems to be that userform5 is modal, but why would it generate this error at debug stage? :/

Thanks guys!

  • #7

Is UserForm5.Combobox2_Change a Private sub?

if so, you could add another sub to userform5

Code:

Public Sub pseudoCombobox2_Change
   ComboBox2_Change
End Sub

And change the line in the calling event to

Code:

UserForm5.pseudoComboBox2_Change

Last edited: Mar 11, 2010

  • #8

Hi Mike,

Ok, think i’m getting maybe closer because the code no longer errors, but nothing happens:

Code:

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
If ListBox1.ListIndex = -1 Then Exit Sub
If ListBox1.ListCount = 1 Then Exit Sub
Dim S As Integer
S = ListBox1.List(ListBox1.ListIndex, 0)
If ComboBox1.Value = "Projects" Then GoTo 20
UserForm3.Hide
Load UserForm4
UserForm4.ComboBox3.Value = S: UserForm4.ComboBox3_Change
UserForm4.Show
Exit Sub
20
UserForm3.Hide
Load UserForm5
UserForm5.Show
UserForm5.ComboBox2.Value = S
UserForm5.pseudoCombobox2_Change
End Sub

So my userform3 stays put and refuses to budge! (again, if combobox2.value isn’t on «Projects» userform4 fires up ok)

  • #9

The UserForm 5 that you are talking to is invisible. I don’t know whether what UF5.CB2 Change is doing depends on UF5 being visible. Or if it tests for .ListIndex = -1. (setting the Value of a ComboBox may not set the ListIndex to the appropriate value)

As a workaround you might try (in UF5)

Code:

Dim Fire5Change as Boolean

Sub pseuoComboBox2_Change(arg As Integer)
    Fire5Change = True
    With Me
        .ComboBox2.Value = arg
        .Show
     End With
End Sub

Private Sub UserForm_Activate()
     If Fire5Change Then ComboBox5_Change
     Fire5Change = False
End Sub

With the calling code

Code:

'...
UserForm3.Hide
UserForm5.pseudoCombobox2_Change S

Rem remove Load UserForm5
Rem remove UserForm5.Show
Rem remove UserForm5.ComboBox2.Value = S
Rem remove UserForm5.pseudoCombobox2_Change

End Sub

Depending on how UF5 is structured, it might need more tweaking to exit that form gracefully.
When a Userform is shown from an instruction inside its own code module, the Terminate event can throw unexpected errors.

Last edited: Mar 11, 2010

Feb 23rd, 2018, 11:45 AM


#1

BettyCrocker is offline

Thread Starter


New Member


«Method or Data Member Not Found» VBA issues in excel

Hi there,

I have no clue what I’m doing but I have copied some code and adjusted to try and fit my purposes but for some reason the first line in my code is causing an issue. I keep getting the error message of «Method or Data Member Not Found» and then when I go to de-bug it is highlighting the first line, which reads:

Private Sub cmdAdd_Click()

I am trying to make a form to add the details of a new supplier to a spreadsheet. I have downloaded the practice sheet and opened that up and it’s working fine, but for some reason it has an issue with the first line in my sheet.

I have deleted some .exd files as suggested in another post but this hasn’t done anything.

Microsoft Office 365, Excel Version 1801 (Build 9001.2171)

I have no idea what VBA version I m running or even how to check — I also have no idea about coding, I just want a form!! Is there a simpler way to make a form to enter into a list of suppliers?? This seems so so long winded…

Entire Code Text:

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets(«Suppliers»)

‘find first empty row in database
iRow = ws.Cells.Find(What:=»*», SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1

‘check for a name
If Trim(Me.txtName.Value) = «» Then
Me.txtName.SetFocus
MsgBox «Please enter a supplier name»
Exit Sub
End If

‘copy the data to the database
‘use protect and unprotect lines,
‘ with your password
‘ if worksheet is protected
With ws
‘ .Unprotect Password:=»password»
.Cells(iRow, 1).Value = Me.txtName.Value
.Cells(iRow, 2).Value = Me.txtWebsite.Value
.Cells(iRow, 3).Value = Me.txtPhoneNo.Value
.Cells(iRow, 4).Value = Me.txtAccountNo.Value
.Cells(iRow, 5).Value = Me.txtEmail.Value
.Cells(iRow, 6).Value = Me.txtContact.Value
.Cells(iRow, 7).Value = Me.txtCategory.Value
.Cells(iRow, 8).Value = Me.txtOpened.Value
.Cells(iRow, 9).Value = Me.txtUsername.Value
.Cells(iRow, 10).Value = Me.txtPassword.Value
‘ .Protect Password:=»password»
End With

‘clear the data

Me.txtName.Value = «»
Me.txtWebsite.Value = «»
Me.txtPhoneNo.Value = «»
Me.txtAccountNo.Value = «»
Me.txtEmail.Value = «»
Me.txtContact.Value = «»
Me.txtCategory.Value = «»
Me.txtOpened.Value = «»
Me.txtUsername.Value = «»
Me.txtPassword.Value = «»
Me.txtName.SetFocus
End Sub


Feb 23rd, 2018, 05:37 PM


#2

Re: «Method or Data Member Not Found» VBA issues in excel

Hi BettyCrocker,
The highlight first line will be yellow to indicates error in routine.
If you scroll down the actual error line will be highlight too in blue.
which line is highlighted blue?


Feb 23rd, 2018, 08:57 PM


#3

Re: «Method or Data Member Not Found» VBA issues in excel

Is there a simpler way to make a form to enter into a list of suppliers??

this is simple, it may be possible to make the code shorter, but it may mean redesigning your form a bit

«Method or Data Member Not Found»

is this procedure (sub) actually in the code pane for the userform or in a general module? for the me keyword to be valid, the code would need to be in the form containing the textboxes, else you would need to specify the form by name

i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

come back and mark your original post as resolved if your problem is fixed
pete


Mar 9th, 2018, 08:15 AM


#4

BettyCrocker is offline

Thread Starter


New Member


Re: «Method or Data Member Not Found» VBA issues in excel

«which line is highlighted blue?[/QUOTE]»

‘check for a name
If Trim(Me

.txtName.Value) = «» Then
Me.txtName.SetFocus
MsgBox «Please enter a supplier name»
Exit Sub
End If

«.txtName»


Mar 9th, 2018, 08:18 AM


#5

BettyCrocker is offline

Thread Starter


New Member


Re: «Method or Data Member Not Found» VBA issues in excel

«is this procedure (sub) actually in the code pane for the userform or in a general module? for the me keyword to be valid, the code would need to be in the form containing the textboxes, else you would need to specify the form by name «

I have zero clue what you’re asking me sorry.


Mar 9th, 2018, 04:43 PM


#6

Re: «Method or Data Member Not Found» VBA issues in excel

the error indicates there is no object (textbox) with the name txtName in the me object

Me would refer to a userform, worksheet or other object and for it to be valid the code would have to be in the code module for that object
possibly replace the ME keyword, with the name of the textboxes container, like userform1.txtname

or post a sample workbook (zip first) with userform that demonstrates the problem

i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

come back and mark your original post as resolved if your problem is fixed
pete


Jun 9th, 2020, 06:33 AM


#7

kamalrana434 is offline


New Member


Re: «Method or Data Member Not Found» VBA issues in excel

Hi I am getting same error. Pls help

Sub Reset()

Dim iRow As Long

iRow = [Counta(Database!A:A)] ‘ idetifying the last row

With frmForm

.txtFinancialYear.Value = «»
.txtMonth.Value = «»
.txtProductionNos.Value = «»
.txtSquareFeet.Value = «»
.txtProductionValue.Value = «»


Jun 9th, 2020, 06:33 AM


#8

kamalrana434 is offline


New Member


Re: «Method or Data Member Not Found» VBA issues in excel

Hi I am getting same error. Pls help

Sub Reset()

Dim iRow As Long

iRow = [Counta(Database!A:A)] ‘ idetifying the last row

With frmForm

.txtFinancialYear.Value = «»
.txtMonth.Value = «»
.txtProductionNos.Value = «»
.txtSquareFeet.Value = «»
.txtProductionValue.Value = «»


Jun 9th, 2020, 04:06 PM


#9

Re: «Method or Data Member Not Found» VBA issues in excel

on which line does the error occur?
is this in access?

i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

come back and mark your original post as resolved if your problem is fixed
pete


I have an .xlam that provides a project code lookup dialog that fills in some metadata on a sheet. The FindProjectForm has a SubmitButton_Click that calls a function FindProject that populates a results list on the form. It is defined in a separate module called ReferenceApi and uses Web API calls. This function works fine if the .xlam is loaded using FileOpen, but if the Add-In is installed it fails the first time it is used with VBA Compile error: Method or data member not found, and opens the debugger at the SubmitButton_Click with FindProject in blue.

  • If you simply close the debugger and try again it works fine thereafter.

  • prefixing FindProject with ReferenceApi.FindProject — no fix.

  • Excel 2013 on MS Windows.

  • FindProject is public and used in other places too.

Private Sub SubmitButton_Click()
    ResultsLabel = "finding:" & NameText
    Set Response = FindProject(NameText, testMode)


Public Function FindProject(ByVal search As String, ByVal test As Boolean)
'
' Call API to check a project code in search
'

Понравилась статья? Поделить с друзьями:
  • Compile error invalid use of property
  • Compile error invalid outside procedure excel
  • Compile error invalid or unqualified reference vba
  • Compile error invalid next control variable reference
  • Compile error invalid character