Code equivalent to the Enter-Key

J

JMay

Awhile back I had the [VBA]code line for the
keyboard equivalent of pressing the ENTER Key;
Can someone supply,
Maybe this time I can file it better
so that I can access it six months from now..

TIA,
 
J

JMay

Thanks Tom;
Actually here is my code:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
Target.Font.Name = "Marlett"
If Target = vbNullString Then
Target = "a"
Else
Target = vbNullString
End If
End If
<<<<<<<< SendKeys ("{Enter}") My requested way of completing
the Macro. See below
End Sub

When I double-click on say A5 the Check mark appears but my cursor is
"sitting, waiting and blinking" one character
to the right, as if the value has not been entered.. That is why I was
asking for the above, so as to complete the assignment
of the value to the cell A5.




Tom Ogilvy said:
Sendkeys "~"
or
sendkeys "{enter}"

or do you mean

vbCrLf

--
Regards,
Tom Ogilvy


JMay said:
Awhile back I had the [VBA]code line for the
keyboard equivalent of pressing the ENTER Key;
Can someone supply,
Maybe this time I can file it better
so that I can access it six months from now..

TIA,
 
T

Tom Ogilvy

Private Sub Worksheet_BeforeDoubleClick( _
byVal Target As Range, Cancel As Boolean)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
Target.Font.Name = "Marlett"
If Target = vbNullString Then
Target = "a"
Else
Target = vbNullString
End If
End If
Cancel = True
End Sub


setting cancel to True will solve that problem.

--
regards,
Tom Ogilvy


JMay said:
Thanks Tom;
Actually here is my code:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
Target.Font.Name = "Marlett"
If Target = vbNullString Then
Target = "a"
Else
Target = vbNullString
End If
End If
<<<<<<<< SendKeys ("{Enter}") My requested way of completing
the Macro. See below
End Sub

When I double-click on say A5 the Check mark appears but my cursor is
"sitting, waiting and blinking" one character
to the right, as if the value has not been entered.. That is why I was
asking for the above, so as to complete the assignment
of the value to the cell A5.




Tom Ogilvy said:
Sendkeys "~"
or
sendkeys "{enter}"

or do you mean

vbCrLf

--
Regards,
Tom Ogilvy


JMay said:
Awhile back I had the [VBA]code line for the
keyboard equivalent of pressing the ENTER Key;
Can someone supply,
Maybe this time I can file it better
so that I can access it six months from now..

TIA,
 
B

Bob Phillips

JMay,

Try this

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
With Target
If .Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
.Font.Name = "Marlett"
If .Value = vbNullString Then
.Value = "a"
Else
.Value = vbNullString
End If
Cancel = True
End If
End With
End Sub



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

JMay said:
Thanks Tom;
Actually here is my code:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
Target.Font.Name = "Marlett"
If Target = vbNullString Then
Target = "a"
Else
Target = vbNullString
End If
End If
<<<<<<<< SendKeys ("{Enter}") My requested way of completing
the Macro. See below
End Sub

When I double-click on say A5 the Check mark appears but my cursor is
"sitting, waiting and blinking" one character
to the right, as if the value has not been entered.. That is why I was
asking for the above, so as to complete the assignment
of the value to the cell A5.




Tom Ogilvy said:
Sendkeys "~"
or
sendkeys "{enter}"

or do you mean

vbCrLf

--
Regards,
Tom Ogilvy


JMay said:
Awhile back I had the [VBA]code line for the
keyboard equivalent of pressing the ENTER Key;
Can someone supply,
Maybe this time I can file it better
so that I can access it six months from now..

TIA,
 
J

JMay

Much appreciated, Tom
JMay

Tom Ogilvy said:
Private Sub Worksheet_BeforeDoubleClick( _
byVal Target As Range, Cancel As Boolean)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
Target.Font.Name = "Marlett"
If Target = vbNullString Then
Target = "a"
Else
Target = vbNullString
End If
End If
Cancel = True
End Sub


setting cancel to True will solve that problem.

--
regards,
Tom Ogilvy


JMay said:
Thanks Tom;
Actually here is my code:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
Target.Font.Name = "Marlett"
If Target = vbNullString Then
Target = "a"
Else
Target = vbNullString
End If
End If
<<<<<<<< SendKeys ("{Enter}") My requested way of completing
the Macro. See below
End Sub

When I double-click on say A5 the Check mark appears but my cursor is
"sitting, waiting and blinking" one character
to the right, as if the value has not been entered.. That is why I was
asking for the above, so as to complete the assignment
of the value to the cell A5.




Tom Ogilvy said:
Sendkeys "~"
or
sendkeys "{enter}"

or do you mean

vbCrLf

--
Regards,
Tom Ogilvy


Awhile back I had the [VBA]code line for the
keyboard equivalent of pressing the ENTER Key;
Can someone supply,
Maybe this time I can file it better
so that I can access it six months from now..

TIA,
 
J

JMay

Nice Bob;
Tks,
JMay

Bob Phillips said:
JMay,

Try this

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
With Target
If .Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
.Font.Name = "Marlett"
If .Value = vbNullString Then
.Value = "a"
Else
.Value = vbNullString
End If
Cancel = True
End If
End With
End Sub



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

JMay said:
Thanks Tom;
Actually here is my code:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
Target.Font.Name = "Marlett"
If Target = vbNullString Then
Target = "a"
Else
Target = vbNullString
End If
End If
<<<<<<<< SendKeys ("{Enter}") My requested way of completing
the Macro. See below
End Sub

When I double-click on say A5 the Check mark appears but my cursor is
"sitting, waiting and blinking" one character
to the right, as if the value has not been entered.. That is why I was
asking for the above, so as to complete the assignment
of the value to the cell A5.




Tom Ogilvy said:
Sendkeys "~"
or
sendkeys "{enter}"

or do you mean

vbCrLf

--
Regards,
Tom Ogilvy


Awhile back I had the [VBA]code line for the
keyboard equivalent of pressing the ENTER Key;
Can someone supply,
Maybe this time I can file it better
so that I can access it six months from now..

TIA,
 

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