Amandine FAURILLOU
Amandine FAURILLOU

Reputation: 612

VBA: Show listbox on click

I searched for a way to show a listbox on certain event, here a click, but wasn't able to find it

 If MsgBox("Souhaitez vous reprendre un bordereau déjà édité?", vbYesNo, "Edition Bordereau") = vbYes Then
 PreCheckPlot
 Else
rest of commands

And the sub where I want to show the listbox

Sub PreCheckPlot()
ListBox2.Visible = True
End Sub

This doesn't work, and ListBox2.Show doesn't either, it throws an error.

Is it possible to show a listbox on a click, and if yes, how would I write it?

Thank you in advance.

Upvotes: 1

Views: 1323

Answers (2)

Jean-Pierre Oosthuizen
Jean-Pierre Oosthuizen

Reputation: 2693

You need to refer to the Sheet as well.

So if your ListBox2 is in Sheet1 then you need to use:

 Sheet1.ListBox2.Visible = True

Upvotes: 1

Jpad Solutions
Jpad Solutions

Reputation: 332

Does it go into PreCheckPlot when you step through? What is the error?

If you create a userform, put a listbox on it and a button which when pressed shows your message your code then works fine.

I wonder if you are trying to set ListBox2.Visible from outside the form (where it will not know what the form is)

This assumes it is an ActiveX listbox - or is it a forms listbox?

Upvotes: 1

Related Questions