View Full Version : [SOLVED:] List Box - Reset Button - Search Filter Clear
hi folks,
i am having listbox problems.
i am not sure what i have done wrong on my list box reset , the reset button doesnt work any more.
I search for items and then i would like to reset back to original search - well I'm not sure i can do it justice explaining it so I atatched my book
please take a look
thank you:)
Paul_Hossler
03-23-2017, 01:40 PM
Try moving the Dim of arrList to the module level, instead of inside UserForm_Initialize
Dim arrList(6, 4) ' <<<<<<<<<<<<<<<<<<<<<<< Rows , Columns in Array
Private Sub cmdResetList_Click()
Me.ListBox100.List = arrList
Me.TextBox1 = vbNullString
End Sub
Private Sub UserForm_Initialize()
Dim I
ListBox100.ColumnCount = 4
'---- Listbox Index Numbers
Thanks Paul,
I’ve been at it again butchering my code thanks to misinformation - and I’ve scoured the net to no avail
I just don’t have the wisdom to know where to put these things -
in the Microsoft web page where i got my array from they put it exactly where I put it
Oh well after 3 hours of stress, I better get me self a cuppa and one for you too
Thanks for that
:beerchug:
Paul_Hossler
03-24-2017, 06:30 AM
Thanks Paul,
I just don’t have the wisdom to know where to put these things -
in the Microsoft web page where i got my array from they put it exactly where I put it
:beerchug:
I suspect that in the MS web page, the variable arrList scoped only to the sub UserForm_Initialize (i.e. only used in)
When you added cmdResetList_Click, arrList was invisible (i.e. out of scope) to your sub
By moving the Dim to outside of any procedure (i.e. module level) is was now in scope for subs and functions IN THAT MODULE
Using Public arrList () .... would make it in scope for ALL MODULES
Night time reading ...
https://support.microsoft.com/en-us/help/141693/scope-of-variables-in-visual-basic-for-applications
http://www.cpearson.com/excel/scope.aspx
Be advised that if you had Dim arrList in Userform_Initialize and Dim arrList at the module level, within the UF_Init sub, it's arrList would be used, but every one else would use the module's arrList
Gets messy, and I never have the same name on different scoped variables
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.