Robert Crandal presented the following explanation :
Can you show us what you've been trying? OR are you just wanting someone to
write it for you?
Suggestion:
Would using a 2-column listbox with its 'Sorted' property set to 'True'
work? If so then you could use InputBox to get values from the user. All
could be handled by the listbox's DoubleClick event.
Sure, I can show you some bits of my code, but I'm also willing to
look at someone else's code for alternative solutions.
I first created a global array of strings in one module. The global
declaration looks like this:
Public g_Arr() As String ' My global array of strings
Then, when the userform is created during "UserForm_Initialize()",
I call "ReDim g_Arr" to resize that array to match the current number
of elements in column A. I then load all strings into the "g_Arr" array.
Next, I then call the function below to sort the array:
'---------------------------------------------------
Sub Sort_Array_of_Strings(Arr() As String) ' g_Arr is passed in here!
Dim i, j As Integer
Dim str1, str2 As String
For i = 0 To UBound(Arr)
For j = i To UBound(Arr)
If UCase(Arr(j)) < UCase(Arr(i)) Then
str1 = Arr(i)
str2 = Arr(j)
Arr(i) = str2
Arr(j) = str1
End If
Next j
Next i
End Sub
'------------------------------------------------
One of my main problems is that the sorted list of strings in the listbox
does
NOT match the unsorted order of the data on the spreadsheet, which
makes it hard to find the correct row index. Does that make sense?
Also, I would really prefer to solve this using a one column listbox,
not a two column listbox.
Does anyone have any other ideas? I would appreciate it.
- Robert C.
Thanks! -This helps.
You could use a 1-column listbox.
Is there some reason why the list on the wks can't be sorted? This
would solve the issue of finding the item on the sheet.
Would you want the item to scroll to the top of the window? OR just
select the item, whereby it will scroll into view at top/bottom
accordingly?
Are you aware that setting the Rowsource property causes changes to
update in the listbox immediately? This means the macro can set the
value in the target cell and the listbox will update itself to reflect
that.
--
Garry
Free usenet access at
http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc