PC Review


Reply
Thread Tools Rate Thread

creating an event of pressing 'enter' using VB

 
 
=?Utf-8?B?QW1pdA==?=
Guest
Posts: n/a
 
      12th Oct 2006
I would like to write a subroutine which should initiate after a value is
entered in a cell and enter is pressed. Can smbdy help me out?
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      12th Oct 2006
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1:H10" '<=== change to suit

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
'do your stuff
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Amit" <(E-Mail Removed)> wrote in message
news:C233BE42-4C01-4399-BF56-(E-Mail Removed)...
> I would like to write a subroutine which should initiate after a value is
> entered in a cell and enter is pressed. Can smbdy help me out?



 
Reply With Quote
 
=?Utf-8?B?QW1pdA==?=
Guest
Posts: n/a
 
      12th Oct 2006
Thank You BOB. It solved my problem!

"Bob Phillips" wrote:

> Private Sub Worksheet_Change(ByVal Target As Range)
> Const WS_RANGE As String = "H1:H10" '<=== change to suit
>
> On Error GoTo ws_exit:
> Application.EnableEvents = False
> If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
> With Target
> 'do your stuff
> End With
> End If
>
> ws_exit:
> Application.EnableEvents = True
> End Sub
>
> 'This is worksheet event code, which means that it needs to be
> 'placed in the appropriate worksheet code module, not a standard
> 'code module. To do this, right-click on the sheet tab, select
> 'the View Code option from the menu, and paste the code in.
>
>
>
>
> --
> HTH
>
> Bob Phillips
>
> (replace somewhere in email address with gmail if mailing direct)
>
> "Amit" <(E-Mail Removed)> wrote in message
> news:C233BE42-4C01-4399-BF56-(E-Mail Removed)...
> > I would like to write a subroutine which should initiate after a value is
> > entered in a cell and enter is pressed. Can smbdy help me out?

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
MDI forms - pressing on toolbar doesn't start the enter or activate event ari Microsoft VB .NET 2 29th Mar 2006 02:38 PM
W/o pressing the Enter key.... =?Utf-8?B?QW5nZWxv?= Microsoft Word Document Management 4 17th Feb 2006 12:38 AM
How do I set a botton's click event to execute pressing the Enter =?Utf-8?B?RWR1YXJkbzc4?= Microsoft VB .NET 1 10th Nov 2005 04:53 AM
Tab by pressing <Enter> key =?Utf-8?B?Ymg=?= Microsoft Dot NET 4 16th Jun 2005 08:45 PM
Pressing ENTER Jenna Microsoft Excel Worksheet Functions 1 26th Feb 2004 03:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:44 PM.