LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Is refreshing listbox rowsource in listbox click event possible?

Explanation:
The source data the listbox contains is in columns A, B and C of Sheet1. I
use the rowsource property so the listbox list can have headers.
"WorkList" is a dynamically updating named range. When a selection is made
in Listbox1, the selection is moved to the top of the list on Sheet1 and the
rest of the list is sorted. Everything works great to that point, the
problem is that when I reset the RowSource property, the Listbox1 list
doesn't get updated. I assume this is because it is from Listbox1's click
event, as it works if I do the same thing from another procedure. Am I
doing something wrong, or is there possibly another way to accomplish this?

Thanks!
-Jeremy

----------------------------------------------------------------------------
Private Sub Listbox1_Click()
Dim rng As Range

If DisableFormEvents Then Exit Sub

With Worksheets("Sheet1")
Set rng = .Columns(1).Find(What:=Me.Listbox1, LookIn:=xlValues)
Range(rng, rng(1, 3)).Cut
.Range("A2").Insert Shift:=xlDown
With Range(.Range("A3"), .Cells(.Rows.Count, 26).End(xlUp))
.Sort Key1:=Range("A3"), Order1:=xlAscending,
End With
DisableFormEvents = True
Me.Listbox1.RowSource = _
.Names("WorkList").RefersToRange.Address(External: =True)
DisableFormEvents = False
End With

End Sub
----------------------------------------------------------------------------









 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listbox rowsource on Userform Wendy Excel Discussion (Misc queries) 6 February 28th 08 05:46 PM
capture listbox click Joanne New Users to Excel 13 July 7th 07 01:00 PM
ListBox Click Event BHatMJ Excel Discussion (Misc queries) 6 June 21st 07 09:34 PM
???Help??? Userform.Listbox.rowsource = ??? Steve Sparti Excel Discussion (Misc queries) 0 March 1st 06 09:44 PM
listbox rowsource Christy[_2_] Excel Programming 4 September 20th 03 11:44 PM


All times are GMT +1. The time now is 03:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"