2

Struggling to find any info on how to refer to a listbox in a worksheet (using MS Forms reference) from within a module (not a worksheet or form) in Excel.

Dim lb As MSForms.ListBox
Dim chartSheet as worksheet

    Set chartSheet = Sheets("Chart")

    Set lb = chartSheet.Objects("lbPartNo") ' nope
    Set lb = chartSheet.ListObjects("lbPartNo") ' nope
    Set lb = chartSheet.ListBoxes("lbPartNo") ' nope

Any ideas? Thanks

1 Answer 1

3

If it's actually an MSForms.Listbox (i.e. ActiveX) then:

Set lb = chartSheet.lbPartNo

Otherwise, declare it as just Listbox and use:

 Set lb = chartSheet.ListBoxes("lbPartNo")
Sign up to request clarification or add additional context in comments.

1 Comment

Ah OK, I was confusing plain old listboxes with the library for the ActiveX control. Thanks a bunch.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.