LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Enter Command

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lock Cell After Enter Command DOUG Excel Discussion (Misc queries) 5 March 2nd 09 06:18 PM
Using command buttons to enter data Nick T Excel Discussion (Misc queries) 1 January 12th 07 02:20 PM
Why does the error pop up- can't enter command mode? Thief_ Excel Programming 0 April 7th 05 06:43 AM
how do i enter data using formula and the Copy command For exa. 5494 New Users to Excel 0 January 28th 05 05:55 AM
Run command when hitting ENTER on list box item Mr. Smith Excel Programming 1 October 28th 03 01:13 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"