List Box: How to copy clicked items on current sheet active cell?

poli9

New Member
Joined
Aug 6, 2016
Messages
16
Office Version
  1. 2021
Platform
  1. Windows
Hi,

I'm running Excel 2021.

I have a created a "List Box" (from Developer/Insert/Form Controls/List Box) on Sheet1.
It is filled with a list of values from Sheet2 :

EXCEL_cukNpVVZji.png


Every time I click on an item in this List Box, I want my current cell (I mean the active one where my cursor is in the sheet) to be filled in with the List Box clicked item and then, move down (the new active cell in Sheet1 becomes the next one below, ready to be filled in with a new List Box clicked item).

I also want this List box to remain at the same place even if I scroll Sheet1's window bars. (except I decide to move it (left click on it + right click to move it) )

How can I do this?

Thanks for your help.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Every time I click on an item in this List Box, I want my current cell (I mean the active one where my cursor is in the sheet) to be filled in with the List Box clicked item and then, move down (the new active cell in Sheet1 becomes the next one below, ready to be filled in with a new List Box clicked item).
For that part assign the following macro to your List Box (right-click on it, select Assign Macro, select MyListbox_Click and click OK.

Note: In this line Set shp = ActiveSheet.Shapes("List Box") of the macro fit to the name of your List Box
Put the following code in a module:
VBA Code:
Sub MyListbox_Click()
  Dim shp As Shape
  Dim i As Long
 
  Set shp = ActiveSheet.Shapes("List Box")    'fit to the name of your listbox
  With shp.OLEFormat.Object
    For i = 1 To .ListCount
      If .Selected(i) Then
        ActiveCell.Value = .List(i)
        ActiveCell.Offset(1).Select
        Exit For
      End If
    Next
  End With
End Sub

I also want this List box to remain at the same place even if I scroll Sheet1's window bars. (except I decide to move it (left click on it + right click to move it) )
For that part, look for how to float the shape on the sheet
For example:
 
Last edited:
Upvote 1
Solution

Forum statistics

Threads
1,214,918
Messages
6,122,241
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top