Cursor hidden in ComboBox

dhardister

New Member
Joined
Jun 27, 2018
Messages
2
I have the following code that reveals a ComboBox when a target cell is double clicked

Code:
[FONT=Arial]Private Sub Worksheet_BeforeDoubleClick([/FONT]<wbr style="font-family: Arial, Helvetica, sans-serif;">[FONT=Arial]ByVal Target As Range, _ [/FONT]
[FONT=Arial]  Cancel As Boolean) [/FONT]
[FONT=Arial]Dim str As String [/FONT]
[FONT=Arial]Dim cboTemp As OLEObject [/FONT]
[FONT=Arial]Dim ws As Worksheet [/FONT]
[FONT=Arial]Set ws = ActiveSheet [/FONT]
[FONT=Arial]Set cboTemp = ws.OLEObjects("TempCombo") [/FONT]
[FONT=Arial]  On Error Resume Next [/FONT]
[FONT=Arial]  With cboTemp [/FONT]
[FONT=Arial]  'clear and hide the combo box [/FONT]
[FONT=Arial]    .ListFillRange = "" [/FONT]
[FONT=Arial]    .LinkedCell = "" [/FONT]
[FONT=Arial]    .Visible = False [/FONT]
[FONT=Arial]  End With [/FONT]
[FONT=Arial]On Error GoTo errHandler [/FONT]
[FONT=Arial]  If Target.Validation.Type = 3 Then [/FONT]
[FONT=Arial]    'if the cell contains a data validation list [/FONT]
[FONT=Arial]    'Cancel = True [/FONT]
[FONT=Arial]    Application.EnableEvents = False [/FONT]
[FONT=Arial]    'get the data validation formula [/FONT]
[FONT=Arial]    str = Target.Validation.Formula1 [/FONT]
[FONT=Arial]    str = Right(str, Len(str) - 1) [/FONT]
[FONT=Arial]    With cboTemp [/FONT]
[FONT=Arial]      'show the combobox with the list [/FONT]
[FONT=Arial]      .Visible = True [/FONT]
[FONT=Arial]      .Left = Target.Left [/FONT]
[FONT=Arial]      .Top = Target.Top [/FONT]
[FONT=Arial]      .Width = Target.Width + 100 [/FONT]
[FONT=Arial]      .Height = Target.Height + 1 [/FONT]
[FONT=Arial]      .ListFillRange = ws.Range(str).Address [/FONT]
[FONT=Arial]      .LinkedCell = Target.Address [/FONT]
[FONT=Arial]    End With [/FONT]
[FONT=Arial]    cboTemp.Activate [/FONT]
[FONT=Arial]'    Application.ScreenUpdating = False [/FONT]
[FONT=Arial]'    Worksheets("Instructions").[/FONT]<wbr style="font-family: Arial, Helvetica, sans-serif;">[FONT=Arial]Activate [/FONT]
[FONT=Arial]'    Application.Wait (Now + TimeValue("0:00:01")) [/FONT]
[FONT=Arial]'    Worksheets("Draft_Board").[/FONT]<wbr style="font-family: Arial, Helvetica, sans-serif;">[FONT=Arial]Activate [/FONT]
[FONT=Arial]    'open the drop down list automatically [/FONT]
[FONT=Arial]    'TempCombo.DropDown [/FONT]
[FONT=Arial]  End If [/FONT]
[FONT=Arial]    Application.EnableEvents = True [/FONT]
[FONT=Arial]    Application.ScreenUpdating = True [/FONT]

[FONT=Arial]errHandler: [/FONT]
[FONT=Arial]  Application.EnableEvents = True [/FONT]
[FONT=Arial]  Exit Sub [/FONT]

[FONT=Arial]End Sub [/FONT]

The problem that occurs is a third click is actually required to begin typing into the box. If I click on another worksheet tab and then back to the tab with the ComboBox, the cursor is showing in the box. You can see the remarked code near the end where I tried to accomplish this programmatically, but it doesn't work.

Have any suggestions to uncover the hidden cursor?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
The code here is using Worksheet_SelectionChange but may give some ideas as it kind of looks like the code you're attempting to use from double click.
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,431
Members
452,326
Latest member
johnshaji

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