Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default On event macro

Hi Guys
Can anyone help with some code?
I need to run a macro on input of information in col's B, C or D
running down a number of rows. For e.g. if I input a 1 in col B the
macro needs to run, or a date in col C or D for that matter.
Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default On event macro

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1:C10"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Column = 1 Then
If IsNumeric(.Value) Then
'do your stuff
End If
ElseIf IsDate(.Value) Then
'do your date stuff
End If
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)

"markvdh" wrote in message
oups.com...
Hi Guys
Can anyone help with some code?
I need to run a macro on input of information in col's B, C or D
running down a number of rows. For e.g. if I input a 1 in col B the
macro needs to run, or a date in col C or D for that matter.
Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default On event macro

Thanks Bob, I will try it


Bob Phillips wrote:
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1:C10"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Column = 1 Then
If IsNumeric(.Value) Then
'do your stuff
End If
ElseIf IsDate(.Value) Then
'do your date stuff
End If
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)

"markvdh" wrote in message
oups.com...
Hi Guys
Can anyone help with some code?
I need to run a macro on input of information in col's B, C or D
running down a number of rows. For e.g. if I input a 1 in col B the
macro needs to run, or a date in col C or D for that matter.
Thanks


Reply
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
Event Macro running another macro inside K1KKKA Excel Discussion (Misc queries) 1 December 20th 06 08:21 PM
Help with Event macro..... Celt[_55_] Excel Programming 2 May 1st 06 09:13 PM
Event Macro Quaisne Excel Programming 2 November 23rd 05 11:51 AM
Event Macro? Lisa Excel Programming 4 August 4th 04 10:45 PM
Event Macro Amy Excel Programming 2 August 4th 04 04:55 PM


All times are GMT +1. The time now is 03:40 PM.

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"