View Full Version : Copy selected value from listbox into a cell
Chuck31
12-24-2007, 08:58 AM
Hi all,
I have a listbox and would like that when an item is selected from it, the value will be copied into a cell. If the cell is already full it will go to the next one empty.
Thanks and happy holidays
mikerickson
12-24-2007, 09:47 AM
This should do what you want. The name of the list box, sheet name and cell can be adjusted to your situation.
With ThisWorkbook.Sheets("Sheet1")
With .Range("d1")
Select Case True
Case .Value = vbNullString
.Value = .Shapes("List Box 1").ControlFormat.List(.ListIndex)
Case .Offset(1, 0).Value = vbNullString
.Offset(1, 0).Value = .Shapes("List Box 1").ControlFormat.List(.ListIndex)
Case Else
.End(xlDown).Offset(1, 0).Value = .Shapes("List Box 1").ControlFormat.List(.ListIndex)
End Select
End With
End With
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.