ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ListIndex (https://www.excelbanter.com/excel-programming/298181-listindex.html)

Todd huttenstine

ListIndex
 
I have a combobox called ComboBox3. One of the values in
the combobox is "Export from Un-Opened Workbook..."
Now I dont know what position it is in the combobox but I
know I want it moved to the very end. The below code
tells me how many items are in the combobox. If variable
IndxNumber = 4, then I want for the value "Export from Un-
Opened Workbook..." to be moved to listindex postion
number 4 (very last position)

Dim IndxNumber
IndxNumber = ComboBox3.ListIndex + 1


How do I do this?

Thank you
Todd

Bob Phillips[_6_]

ListIndex
 
Hi Tood,

One way

Dim sValue
Dim i As Long
Dim j As Long

With ComboBox1
For i = 0 To .ListCount - 1
If .List(i) = Export from Un-Opened Workbook..." Then
sValue = .List(i)
For j = i To .ListCount - 2
.List(j) = .List(j + 1)
Next j
.List(.ListCount - 1) = sValue
Exit For
End If
Next i
End With



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Todd Huttenstine" wrote in message
...
I have a combobox called ComboBox3. One of the values in
the combobox is "Export from Un-Opened Workbook..."
Now I dont know what position it is in the combobox but I
know I want it moved to the very end. The below code
tells me how many items are in the combobox. If variable
IndxNumber = 4, then I want for the value "Export from Un-
Opened Workbook..." to be moved to listindex postion
number 4 (very last position)

Dim IndxNumber
IndxNumber = ComboBox3.ListIndex + 1


How do I do this?

Thank you
Todd




Todd Htutenstine

ListIndex
 
Thanks

-----Original Message-----
Hi Tood,

One way

Dim sValue
Dim i As Long
Dim j As Long

With ComboBox1
For i = 0 To .ListCount - 1
If .List(i) = Export from Un-Opened

Workbook..." Then
sValue = .List(i)
For j = i To .ListCount - 2
.List(j) = .List(j + 1)
Next j
.List(.ListCount - 1) = sValue
Exit For
End If
Next i
End With



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Todd Huttenstine"

wrote in message
...
I have a combobox called ComboBox3. One of the values

in
the combobox is "Export from Un-Opened Workbook..."
Now I dont know what position it is in the combobox but

I
know I want it moved to the very end. The below code
tells me how many items are in the combobox. If

variable
IndxNumber = 4, then I want for the value "Export from

Un-
Opened Workbook..." to be moved to listindex postion
number 4 (very last position)

Dim IndxNumber
IndxNumber = ComboBox3.ListIndex + 1


How do I do this?

Thank you
Todd



.



All times are GMT +1. The time now is 07:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com