Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Worksheet Change Event

This is what I'm currently using: The event triggers whenever a value i
enter manually anywhere in column "b" and a timestamp is added in colum
z.

My goal is to trigger this event when "pasting a new value" in colum
"b".

See the code that follows this example. I accidentally found it in thi
forum and I'm hoping it could be modified by an expert to meet m
requirement. TIA everybody!

Private Sub Worksheet_Change(ByVal Target As Range)

If Intersect(Target, Me.Range("b:b")) Is Nothing Then Exit Sub
If Target.Cells.Count 1 Then Exit Sub

Application.EnableEvents = False

On Error GoTo errHandler:
With Target.Offset(0, 24)
.Value = Now 'date
.NumberFormat = "mm/dd/yyyy hh:mm"
End With

errHandler:
Application.EnableEvents = True
End Sub

The following code works "if" information is pasted in a range.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
Dim changecolumn As Integer
Dim changerow As Integer
Dim changeworker As String

On Error GoTo errhandler:
Application.ScreenUpdating = False
Application.EnableEvents = False

For Each cell In Target
changecolumn = cell.Column
changerow = cell.Row
changeworker = 0
If changecolumn = 89 Then Exit For
Call change_flag(changerow, 1000, Me, changeworker)
Next

errhandler:
Application.EnableEvents = True
End Su

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Worksheet Change Event

Hi
try
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
If Intersect(Target, Me.Range("b:b")) Is Nothing Then Exit
Sub
Application.EnableEvents = False
Application.ScreenUpdating = False

On Error GoTo errHandler:
For Each cell In Target
With cell.Offset(0, 24)
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm"
End With
Next
errHandler:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub

-----Original Message-----
This is what I'm currently using: The event triggers

whenever a value is
enter manually anywhere in column "b" and a timestamp is

added in column
z.

My goal is to trigger this event when "pasting a new

value" in column
"b".

See the code that follows this example. I accidentally

found it in this
forum and I'm hoping it could be modified by an expert to

meet my
requirement. TIA everybody!

Private Sub Worksheet_Change(ByVal Target As Range)

If Intersect(Target, Me.Range("b:b")) Is Nothing Then

Exit Sub
If Target.Cells.Count 1 Then Exit Sub

Application.EnableEvents = False

On Error GoTo errHandler:
With Target.Offset(0, 24)
.Value = Now 'date
.NumberFormat = "mm/dd/yyyy hh:mm"
End With

errHandler:
Application.EnableEvents = True
End Sub

The following code works "if" information is pasted in a

range.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
Dim changecolumn As Integer
Dim changerow As Integer
Dim changeworker As String

On Error GoTo errhandler:
Application.ScreenUpdating = False
Application.EnableEvents = False

For Each cell In Target
changecolumn = cell.Column
changerow = cell.Row
changeworker = 0
If changecolumn = 89 Then Exit For
Call change_flag(changerow, 1000, Me, changeworker)
Next

errhandler:
Application.EnableEvents = True
End Sub


---
Message posted from http://www.ExcelForum.com/

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Worksheet Change Event

Thanks Frank,

However, 2 things began to happen:

1) when I copy and paste one row with 3 columns of info from on
workbook to the other, timestamp is added from column z tru column ab.

If I paste 8 cells, then timestamp is added from z tru column ag (
columns)


2) If I clear or delete an entire row, then timestamp is added fro
column z tru column iv (the last column in the workbook)

I guess the target is still not specific enough... I don't know

- Larry -
VBA Amateu

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Worksheet Change Event

no solution? :(

Can the code be disable when deleting rows

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Worksheet Change Event

How about:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myCell As Range
Dim myRngToCheck As Range

Set myRngToCheck = Me.Range("b:B")

If Intersect(Target, myRngToCheck) Is Nothing Then Exit Sub

On Error Resume Next
Application.EnableEvents = False
For Each myCell In Intersect(Target, myRngToCheck).Cells
With myCell
If IsError(.Value) Then
'do nothing???
ElseIf .Value = "" Then
.Offset(0, 24).ClearContents
Else
.Offset(0, 24).Value = Now
.Offset(0, 24).NumberFormat = "mm/dd/yyyy hh:mm"
End If
End With
Next myCell
Application.EnableEvents = True

End Sub

Since you might be doing lots of things, this one just flies by any errors and
keeps going.



"nrage21 <" wrote:

no solution? :(

Can the code be disable when deleting rows?

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson



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
Worksheet Change event LAF Excel Discussion (Misc queries) 3 January 4th 06 02:08 AM
Worksheet Change Event TonyM Excel Discussion (Misc queries) 8 March 11th 05 12:52 PM
worksheet change event gautamvt Excel Programming 1 December 10th 03 05:15 PM
Worksheet change event Helen Trim[_3_] Excel Programming 0 September 23rd 03 03:00 PM
Worksheet Change Event Help Please J P Singh Excel Programming 1 July 16th 03 09:37 AM


All times are GMT +1. The time now is 02:12 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"