Drop down list to drop with cell selection.

litlwillie

New Member
Joined
Jan 16, 2008
Messages
42
I have a spreadsheet with drop down lists in 2 different cells. I would like for the list to drop down when the cell is selected. If I can get this to work I have additional lists I'd like to create. I have some knowledge of programming with VBA and this seems to be the kind of thing that could be done in VBA. Thanks in advance I've always found users here to be very knowledgable.
 
Last edited:

litlwillie

New Member
Joined
Jan 16, 2008
Messages
42
Thanks Andrew,
The lists work fine right now. I'm just trying to keep from having to click twice once to activate the list and then on the arrow to drop the list. I don't think you can do that with Data Validation alone.
 

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
22,775
You might try something like this. The SendKeys as written will probably have to be changed to the correct Windows key combination.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    If Target.Cells.Count = 1 Then
        On Error Resume Next
        With ActiveCell.Validation
            If Not (.Type = 3 And .InCellDropdown) Then
                Rem not list validation
            Else
                On Error GoTo 0
                If Application.OperatingSystem Like "*Macintosh*" Then
                    On Error Resume Next
                    MacScript ("tell application ""System Events"" " & vbCr & _
                     "tell process ""Microsoft Excel"" " & vbCr & _
                     "keystroke ASCII character 31 using option down" & vbCr & _
                     "end tell" & vbCr & _
                     "end tell")
                     On Error GoTo 0
                Else
                    Application.SendKeys ("#{DOWN}")
                End If
            End If
            On Error GoTo 0
        End With
    End If
End Sub
 

Forum statistics

Threads
1,081,535
Messages
5,359,365
Members
400,525
Latest member
swwber

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top