Double clicking a Cell Programatically

G

Guest

Is it possible to double click a cell "programatically"?

I would like to double click a ComboBox and have it "double click" the cell
that is set as the ComboBox's ControlSource which will then run a macro
residing in the worksheet.

Is this possible? Any help would be greatly appreciated.
 
G

Guest

You can sort of do it functionally. Double-clicking a cell (manually) puts
you in Edit mode. Any characters entered after this will be appended tto the
existing cell contents. It also Selects the cell you double-clicked on.
Lets say we want to do this to cell A1:


Sub pseudo_double_click()
Range("A1").Select
Application.SendKeys "{F2}"
DoEvents
End Sub


This will leave you exactly as if you had double-clicked A1
 
I

IanKR

You can sort of do it functionally. Double-clicking a cell
(manually) puts you in Edit mode.

That only works for me if I have "Tools | Options | Edit | Edit directly in
cell" checked (which I don't usually have) and even then, the insertion
point appears in the cell's current contents relative to where you click in
the cell. To make it appear at the (right) end of the cell's current
contents you first have to make sure the cell's column is wide enough, and
then click far enough over to the right of the cell.
 
G

Guest

I guess that doesn't work for me either.

What I have is code residing in the Worksheet that inserts a cell comment
then displays an InputBox for entering the comment text when a cell is double
clicked. What i'd like this to do is the exact same thing when I double click
a ComboBox and have it insert the comment to the ComboBox's ControlSource
cell.
 
G

Guest

You might try to use the Event code:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

this goes in worksheet code and allows you to execute a macro when you
double-click. I just don't know what your code would do.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top