Try the following (add it to the code module of sheet 1, if that's the sheet
you want to work with):
=========================================
Option Explicit
Private Const lTgtCol As Long = 1
Private Const lTgtRow As Long = 50
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = lTgtRow And Target.Column = lTgtCol Then
If Sheet1.Cells(lTgtRow, lTgtCol).Value = 1 Then
Sheet1.Cells(lTgtRow, lTgtCol).Select
Application.SendKeys "{ENTER}"
End If
End If
End Sub
=========================================
But why do you try to send enter? Is that to "confirm the edit", i.e., when
your ActiveX control is putting the character "1" into cell A50 do you need
to make your VBA code send an Enter keystroke to commit ithe change? If so,
the above attempt using Worksheet_Change() will obviously not work, because
the Change event will not fire before the change of the cell value has been
committed.
Cheers,
/MP
"Lil Pun" wrote:
Also, this is a section of code listed in the ThisWorkbook part of the
Excel VBA code:
Private Sub Workbook_Open()
Range("A2").Select
avoidloop = True
Application.SendKeys "{F2}"
End Sub
I believe this code sends the F2 function to cell A2.
How would I do an "Enter" for th cell A50 but at the same time only
doing it if a 1 were entered into that cell.
--
Lil Pun
------------------------------------------------------------------------
Lil Pun's Profile: http://www.excelforum.com/member.php...o&userid=33840
View this thread: http://www.excelforum.com/showthread...hreadid=549138