SOLVED
Home

Compile error: Method or data member not found

%3CLINGO-SUB%20id%3D%22lingo-sub-210504%22%20slang%3D%22en-US%22%3ECompile%20error%3A%20Method%20or%20data%20member%20not%20found%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-210504%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20using%20three%20List%20Boxes%20on%20one%20sheet%20(the%20Font%20Book%20tab)%2C%20where%20clicking%20one%20deselects%20the%20other%20two.%20The%20worksheet%20functions%20as%20expected%2C%20but%20on%20opening%20the%20workbook%2C%20I%20receive%20the%20%22Compile%20error%22%20popup.%20Specifically%2C%20it%20is%20in%20the%20script%20for%20the%20first%20List%20Box%20(ListBox1)%2C%20and%20VBA%20highlights%20the%20second%20List%20Box%20(ListBox2)%20where%20I'm%20clearing%20the%20List%20Box%20values.%20Any%20assistance%20would%20be%20appreciated.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-210504%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20%26amp%3B%20VBA%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ENeed%20Help%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-210887%22%20slang%3D%22en-US%22%3ERe%3A%20Compile%20error%3A%20Method%20or%20data%20member%20not%20found%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-210887%22%20slang%3D%22en-US%22%3E%3CP%3EYou're%20quite%20welcome.%26nbsp%3B%20Glad%20you%20have%20it%20working.%26nbsp%3B%20Please%20feel%20free%20to%20post%20back%20to%20the%20community%20in%20the%20future%20if%20you%20have%20any%20other%20inquiries.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-210883%22%20slang%3D%22en-US%22%3ERe%3A%20Compile%20error%3A%20Method%20or%20data%20member%20not%20found%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-210883%22%20slang%3D%22en-US%22%3E%3CP%3EExcellent%20-%20thank%20you!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-210619%22%20slang%3D%22en-US%22%3ERe%3A%20Compile%20error%3A%20Method%20or%20data%20member%20not%20found%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-210619%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20had%20the%20code%20in%20a%20code%20module%20and%20a%20worksheet%20code%20module.%26nbsp%3B%20If%20the%20code%20is%20in%20the%20worksheet%20module%20you%20can%20use%20syntax%20like%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3EMe.ListBox2.Value%20%3D%20%22%22%3C%2FPRE%3E%0A%3CP%3EIf%20you%20use%20a%20code%20module%20you%20have%20to%20specify%20the%20worksheet%3A%3C%2FP%3E%0A%3CPRE%3ESheets(%22Font%20Book%22).ListBox2.Value%20%3D%20%22%22%3C%2FPRE%3E%0A%3CP%3EIt%20looks%20like%20your%20code%20was%20duplicative.%26nbsp%3B%20I%20removed%20the%20code%20module%20stuff%20and%20now%20it%20works%20fine%20(See%20attached)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-488112%22%20slang%3D%22en-US%22%3ERe%3A%20Compile%20error%3A%20Method%20or%20data%20member%20not%20found%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-488112%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F37127%22%20target%3D%22_blank%22%3E%40Matt%20Mickle%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAm%20I%20understanding%20correctly%20that%20this%20error%20means%20that%20the%20sheet%20has%20not%20been%20called%20in%20prior%20code%3F%20I%20am%20attempting%20to%20plot%20a%20chart%20and%20am%20calling%20from%20a%20sheet%20called%20Basic%20Duck%20and%20am%20having%20an%20error%20pop%20up%20that%20says%20the%20method%20is%20not%20found.%20I%20previously%20had%20a%20range%20error%20but%20that%20has%20been%20corrected.%20I%20have%20not%20previously%20named%20the%20sheet%20in%20the%20code%20though%20if%20that%20needs%20to%20happen.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F110682i90C57ABE556D5FD5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Screen%20Shot%202019-04-26%20at%205.19.42%20PM.png%22%20title%3D%22Screen%20Shot%202019-04-26%20at%205.19.42%20PM.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-694190%22%20slang%3D%22en-US%22%3ERe%3A%20Compile%20error%3A%20Method%20or%20data%20member%20not%20found%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-694190%22%20slang%3D%22en-US%22%3EHi%20is%20this%20maybe%20the%20same%20error%20I%20am%20seeing%20here%20please%3F%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FExcel%2FCompile-Error-Method-or-data-member-not-found%2Fm-p%2F694161%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FExcel%2FCompile-Error-Method-or-data-member-not-found%2Fm-p%2F694161%3C%2FA%3E%3C%2FLINGO-BODY%3E
Highlighted
kevin whiteside
New Contributor

I'm using three List Boxes on one sheet (the Font Book tab), where clicking one deselects the other two. The worksheet functions as expected, but on opening the workbook, I receive the "Compile error" popup. Specifically, it is in the script for the first List Box (ListBox1), and VBA highlights the second List Box (ListBox2) where I'm clearing the List Box values. Any assistance would be appreciated.

5 Replies
Solution

You had the code in a code module and a worksheet code module.  If the code is in the worksheet module you can use syntax like:

 

Me.ListBox2.Value = ""

If you use a code module you have to specify the worksheet:

Sheets("Font Book").ListBox2.Value = ""

It looks like your code was duplicative.  I removed the code module stuff and now it works fine (See attached)

 

Excellent - thank you!

You're quite welcome.  Glad you have it working.  Please feel free to post back to the community in the future if you have any other inquiries.

@Matt Mickle 

 

Am I understanding correctly that this error means that the sheet has not been called in prior code? I am attempting to plot a chart and am calling from a sheet called Basic Duck and am having an error pop up that says the method is not found. I previously had a range error but that has been corrected. I have not previously named the sheet in the code though if that needs to happen.

 

Screen Shot 2019-04-26 at 5.19.42 PM.png