Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Lock Cell After Enter Command | Excel Discussion (Misc queries) | |||
Using command buttons to enter data | Excel Discussion (Misc queries) | |||
Why does the error pop up- can't enter command mode? | Excel Programming | |||
how do i enter data using formula and the Copy command For exa. | New Users to Excel | |||
Run command when hitting ENTER on list box item | Excel Programming |