ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Double clicking a Cell Programatically (https://www.excelbanter.com/excel-programming/387775-double-clicking-cell-programatically.html)

ToddG[_5_]

Double clicking a Cell Programatically
 
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.

Gary''s Student

Double clicking a Cell Programatically
 
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
--
Gary''s Student - gsnu200716


"ToddG" wrote:

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.


IanKR

Double clicking a Cell Programatically
 
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.



ToddG[_5_]

Double clicking a Cell Programatically
 
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.


"IanKR" wrote:

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.




Gary''s Student

Double clicking a Cell Programatically
 
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.
--
Gary''s Student - gsnu200716


"ToddG" wrote:

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.


"IanKR" wrote:

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.





All times are GMT +1. The time now is 10:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com