How do I exit a cells edit mode?

G

Guest

If you select a cell and press F2, or double click it, the cell will go into
edit mode. I am using the following code to insert ticks and crosses in blank
cells:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If ActiveCell = "û" Or Len(ActiveCell) = 0 Then
ActiveCell.Font.Name = "Wingdings"
ActiveCell.Font.Size = "14"
ActiveCell.Font.ColorIndex = 50
ActiveCell = "ü"
Else
If ActiveCell = "ü" Then
ActiveCell.Font.Name = "Wingdings"
ActiveCell.Font.Size = "14"
ActiveCell.Font.Color = vbRed
ActiveCell = "û"
End If
End If
End Sub

After this code has run the cell goes into edit mode, and as the code runs
'BeforeDoubleClick' I can't get out of edit mode in the code. Any ideas?
 
G

Guest

Through this in at the beginning of your code to stope editing in the cell
Application.EditDirectlyInCell = False
 
G

Gord Dibben

Add the Cancel = True line as shown

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As _
Boolean)
If ActiveCell = "û" Or Len(ActiveCell) = 0 Then
ActiveCell.Font.Name = "Wingdings"
ActiveCell.Font.Size = "14"
ActiveCell.Font.ColorIndex = 50
ActiveCell = "ü"
Else
If ActiveCell = "ü" Then
ActiveCell.Font.Name = "Wingdings"
ActiveCell.Font.Size = "14"
ActiveCell.Font.Color = vbRed
ActiveCell = "û"
End If
End If
Cancel = True 'add this line
End Sub


Gord Dibben MS Excel MVP
 
J

JE McGimpsey

Note that this will disable ALL double clicks, even if the active cell's
value is not "û","ü", or blank (which may be exactly what you want, but
isn't obvious from your code).
 
G

Gord Dibben

Thanks John

Will have to study this some more<g>

I see your second post and will look at that for pointers.


Gord
 
G

Goofball

Hi. Is there any way to cancel Excel edit mode using COM interfaces
from outside?
I mean, can it be canceled from other application that gets pointer to
Excel IDispatch? Any ideas? Thanks.
 

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