ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code equivalent to the Enter-Key (https://www.excelbanter.com/excel-programming/299199-code-equivalent-enter-key.html)

JMay

Code equivalent to the Enter-Key
 
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,



Tom Ogilvy

Code equivalent to the Enter-Key
 
Sendkeys "~"
or
sendkeys "{enter}"

or do you mean

vbCrLf

--
Regards,
Tom Ogilvy


"JMay" wrote in message
news:c45sc.4129$zE6.3489@lakeread06...
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,





Frank Kabel

Code equivalent to the Enter-Key
 
Hi
have a look at the Sendkeys method in the VBA help

--
Regards
Frank Kabel
Frankfurt, Germany


JMay wrote:
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,


JMay

Code equivalent to the Enter-Key
 
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" wrote in message
...
Sendkeys "~"
or
sendkeys "{enter}"

or do you mean

vbCrLf

--
Regards,
Tom Ogilvy


"JMay" wrote in message
news:c45sc.4129$zE6.3489@lakeread06...
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,







Tom Ogilvy

Code equivalent to the Enter-Key
 
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" wrote in message
news:eu5sc.4187$zE6.3864@lakeread06...
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" wrote in message
...
Sendkeys "~"
or
sendkeys "{enter}"

or do you mean

vbCrLf

--
Regards,
Tom Ogilvy


"JMay" wrote in message
news:c45sc.4129$zE6.3489@lakeread06...
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,









Bob Phillips[_6_]

Code equivalent to the Enter-Key
 
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" wrote in message
news:eu5sc.4187$zE6.3864@lakeread06...
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" wrote in message
...
Sendkeys "~"
or
sendkeys "{enter}"

or do you mean

vbCrLf

--
Regards,
Tom Ogilvy


"JMay" wrote in message
news:c45sc.4129$zE6.3489@lakeread06...
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,









JMay

Code equivalent to the Enter-Key
 
Much appreciated, Tom
JMay

"Tom Ogilvy" wrote in message
...
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" wrote in message
news:eu5sc.4187$zE6.3864@lakeread06...
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" wrote in message
...
Sendkeys "~"
or
sendkeys "{enter}"

or do you mean

vbCrLf

--
Regards,
Tom Ogilvy


"JMay" wrote in message
news:c45sc.4129$zE6.3489@lakeread06...
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,











JMay

Code equivalent to the Enter-Key
 
Nice Bob;
Tks,
JMay

"Bob Phillips" wrote in message
...
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" wrote in message
news:eu5sc.4187$zE6.3864@lakeread06...
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" wrote in message
...
Sendkeys "~"
or
sendkeys "{enter}"

or do you mean

vbCrLf

--
Regards,
Tom Ogilvy


"JMay" wrote in message
news:c45sc.4129$zE6.3489@lakeread06...
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,












All times are GMT +1. The time now is 07:18 AM.

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