Share via

Listbox click event

Anonymous
2011-10-06T17:06:06+00:00

Thought this would be straight forword but I can not get it to work.

When I click on a name in ListBox1 I want that value to be placed in cell AA4 of the active sheet. Tried the code below but no luck.

Private Sub ListBox1_Click()

Range("AA4").Value = ListBox1.Value

End Sub

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

5 answers

Sort by: Most helpful
  1. Anonymous
    2011-10-08T15:22:27+00:00

    I did as you suggested. In the ControlSource for the ListBox on my UserForm I entered $AA$4 but when I did that I was no longer able to select anything on the ListBox.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2011-10-07T16:43:58+00:00

    Why not just use the ControlSource of the ListBox?

    Set the ControlSource to $AA$4, and whenever you click on a name on the ListBox, $AA$4 will show that name.

    To do that, select the form in the Visual Basic Editor.  Make sure the Properties window is showing.  Scroll to the ControlSource property, and type in $AA$4.

    HTH,

    Eric

    Was this answer helpful?

    0 comments No comments
  3. HansV 462.6K Reputation points
    2011-10-06T22:46:21+00:00

    Your code should work. Make sure that it is in the userform module, not in a standard module.

    Open the userform in the Visual Basic Editor, then double-click ListBox1. This should take you to the ListBox1_Click event procedure. If not, the code is in the wrong place.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2011-10-06T22:29:19+00:00

    Sorry,

    If is a form on a Userform

    Was this answer helpful?

    0 comments No comments
  5. HansV 462.6K Reputation points
    2011-10-06T21:23:09+00:00

    Is this a Forms list box or an ActiveX list box on a worksheet, or is it a list box on a userform (in the Visual Basic Editor)?

    Was this answer helpful?

    0 comments No comments