PC Review


Reply
Thread Tools Rate Thread

Cell Update on Paste

 
 
Harddrive747
Guest
Posts: n/a
 
      20th Jan 2008
I have the following code, which works terrificially.

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "F18:F450"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Value <> "" Then
.Offset(0, -5).Value = Format(Date, "dd-mmm-yyyy")
End If
End With

End If

Const WS_RANGE_1 As String = "F18:L450"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE_1)) Is Nothing Then
With Target
If .Value <> "" Then
Range("B2").Value = Format(Date, "dd-mmm-yyyy")
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

I use it to update a cell with the current date when something in the
specific range changes. What I normally do on this particular sheet is to
paste values in, because others update the information on the spreadsheet.
What I would like to happen is that when I paste information in from the
clipboard that the date in B2 gets updated with the current date after the
paste.

What do I need to do to modify my code to allow that to happen?

thanks for letting me know.
Terry
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      21st Jan 2008
Have you looked at the Worksheet_Activate or Worksheet_Deactivate events to
see if they would do the trick?

"Harddrive747" wrote:

> I have the following code, which works terrificially.
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> Const WS_RANGE As String = "F18:F450"
>
> On Error GoTo ws_exit:
> Application.EnableEvents = False
> If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
> With Target
> If .Value <> "" Then
> .Offset(0, -5).Value = Format(Date, "dd-mmm-yyyy")
> End If
> End With
>
> End If
>
> Const WS_RANGE_1 As String = "F18:L450"
>
> On Error GoTo ws_exit:
> Application.EnableEvents = False
> If Not Intersect(Target, Me.Range(WS_RANGE_1)) Is Nothing Then
> With Target
> If .Value <> "" Then
> Range("B2").Value = Format(Date, "dd-mmm-yyyy")
> End If
> End With
> End If
>
> ws_exit:
> Application.EnableEvents = True
> End Sub
>
> I use it to update a cell with the current date when something in the
> specific range changes. What I normally do on this particular sheet is to
> paste values in, because others update the information on the spreadsheet.
> What I would like to happen is that when I paste information in from the
> clipboard that the date in B2 gets updated with the current date after the
> paste.
>
> What do I need to do to modify my code to allow that to happen?
>
> thanks for letting me know.
> Terry

 
Reply With Quote
 
Harddrive747
Guest
Posts: n/a
 
      21st Jan 2008
I put this code into both places and it did not work. I did see a post
somewhere and for the lift of me, I can't find it that someone use some type
of command that he said it updated a cell even when a paste happened.

Thanks.

"JLGWhiz" wrote:

> Have you looked at the Worksheet_Activate or Worksheet_Deactivate events to
> see if they would do the trick?
>
> "Harddrive747" wrote:
>
> > I have the following code, which works terrificially.
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > Const WS_RANGE As String = "F18:F450"
> >
> > On Error GoTo ws_exit:
> > Application.EnableEvents = False
> > If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
> > With Target
> > If .Value <> "" Then
> > .Offset(0, -5).Value = Format(Date, "dd-mmm-yyyy")
> > End If
> > End With
> >
> > End If
> >
> > Const WS_RANGE_1 As String = "F18:L450"
> >
> > On Error GoTo ws_exit:
> > Application.EnableEvents = False
> > If Not Intersect(Target, Me.Range(WS_RANGE_1)) Is Nothing Then
> > With Target
> > If .Value <> "" Then
> > Range("B2").Value = Format(Date, "dd-mmm-yyyy")
> > End If
> > End With
> > End If
> >
> > ws_exit:
> > Application.EnableEvents = True
> > End Sub
> >
> > I use it to update a cell with the current date when something in the
> > specific range changes. What I normally do on this particular sheet is to
> > paste values in, because others update the information on the spreadsheet.
> > What I would like to happen is that when I paste information in from the
> > clipboard that the date in B2 gets updated with the current date after the
> > paste.
> >
> > What do I need to do to modify my code to allow that to happen?
> >
> > thanks for letting me know.
> > Terry

 
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
function work with manual update, fails with copy paste > 1 cell marcello121 Microsoft Excel Programming 4 23rd Dec 2009 02:21 PM
How will hyperlink cell reference update after copy paste? bjry Microsoft Excel Worksheet Functions 4 12th May 2009 05:10 PM
How will hyperlink cell reference update after copy paste? bjry Microsoft Excel Worksheet Functions 0 12th May 2009 01:02 AM
Copy and paste cell once! Cell deselects after paste. =?Utf-8?B?U3ByZWFkc2hlZXQgUmFiYml0?= Microsoft Excel Crashes 0 7th Dec 2005 06:37 PM
Copy and Paste macro needs to paste to a changing cell reference =?Utf-8?B?bG91bG91?= Microsoft Excel Programming 0 24th Feb 2005 10:29 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:58 AM.