#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4
Default Help on VBA code

Hi,

I am totally new with VBA and in need of urgent help. I need to have the
timestamp in just one cell, say A4, when an entry is made to any of the cells
in range A4:z500. Based on mcgimpsey's code, how do I change it to have it
work based on my need above? I only know enough to change the range, but I
do not know how to change the code to have the timestamp in just one cell
(A4).

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("A2:A10"), .Cells) Is Nothing Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
.Offset(0, 1).ClearContents
Else
With .Offset(0, 1)
.NumberFormat = "dd mmm yyyy hh:mm:ss"
.Value = Now
End With
End If
Application.EnableEvents = True
End If
End With
End Sub

Thanks a heap!

Maeglin
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,231
Default Help on VBA code

Maeglin wrote...
....
timestamp in just one cell, say A4, when an entry is made to any of the cells
in range A4:z500. Based on mcgimpsey's code, how do I change it to have it

....

If you want a timestamp in cell A4, and the entry range includes A4,
what happens when an entry is made in A4? I'll assume the entry range
is actually A5:Z100.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("A5:Z100"), .Cells) Is Nothing Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
Range("A4").ClearContents
Else
Range("A4").NumberFormat = "dd mmm yyyy hh:mm:ss"
Range("A4").Value = Now
End If
Application.EnableEvents = True
End If
End With
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4
Default Help on VBA code

Oh, I'm sorry... I meant I wanted the timestamp to show in A3 for the range
A4:Z500. Thanks!

"Harlan Grove" wrote:

Maeglin wrote...
....
timestamp in just one cell, say A4, when an entry is made to any of the cells
in range A4:z500. Based on mcgimpsey's code, how do I change it to have it

....

If you want a timestamp in cell A4, and the entry range includes A4,
what happens when an entry is made in A4? I'll assume the entry range
is actually A5:Z100.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("A5:Z100"), .Cells) Is Nothing Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
Range("A4").ClearContents
Else
Range("A4").NumberFormat = "dd mmm yyyy hh:mm:ss"
Range("A4").Value = Now
End If
Application.EnableEvents = True
End If
End With
End Sub


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
Convert a Number Code to a Text Code Traye Excel Discussion (Misc queries) 3 April 6th 07 09:54 PM
Code expantion , with code! Arran Excel Discussion (Misc queries) 7 January 14th 07 01:05 AM
Unprotect Code Module in Code Damien Excel Discussion (Misc queries) 2 April 18th 06 03:10 PM
copying vba code to a standard code module 1vagrowr Excel Discussion (Misc queries) 2 November 23rd 05 04:00 PM
Write a code by code Excel Discussion (Misc queries) 1 March 23rd 05 02:34 PM


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