Forum Discussion

kevin whiteside's avatar
kevin whiteside
Copper Contributor
Jun 28, 2018
Solved

Compile error: Method or data member not found

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.

  • 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)

     

5 Replies

  • Matt Mickle's avatar
    Matt Mickle
    Bronze Contributor

    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)

     

Resources