#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code Bug

Hi...

I'm trying to time stamp a key stroke...when a user keys a
Y I want a cell 3 to the left top enter now(). I think the
code is perfect but it just won't work...Can anyone do
this better...

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("AD8:$AD700")) Is Nothing
Then
If Not IsEmpty(Target) Then
If UCase(Target.Value) = "Y" Then
Target.Offset(0, 3).Value = Now()
Target.Offset(0, 3).NumberFormat = "dd/mm"
Target.EntireColumn.AutoFit
End If
End If
End If

Cheers

GC
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Code Bug

Jack,

What is going wrong? Is it going 3 right instead of 3 up? If so, change
Offset(0, 3) to Offset(-3,0). If not, enlighten us.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Jack Foster" wrote in message
...
Hi...

I'm trying to time stamp a key stroke...when a user keys a
Y I want a cell 3 to the left top enter now(). I think the
code is perfect but it just won't work...Can anyone do
this better...

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("AD8:$AD700")) Is Nothing
Then
If Not IsEmpty(Target) Then
If UCase(Target.Value) = "Y" Then
Target.Offset(0, 3).Value = Now()
Target.Offset(0, 3).NumberFormat = "dd/mm"
Target.EntireColumn.AutoFit
End If
End If
End If

Cheers

GC



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code Bug

It seems to work for me. One thing you may want to do when you'r
changing a cells value using the Worksheet_Change event is to tur
events off before changing the cell and turn it back on afterwards:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("A8:$A700")) Is Nothing Then
If Not IsEmpty(Target) Then
If UCase(Target.Value) = "Y" Then
Application.EnableEvents = False
Target.Offset(0, 3).Value = Now()
Target.Offset(0, 3).NumberFormat = "dd/mm"
Target.EntireColumn.AutoFit
Application.EnableEvents = True
End If
End If
End If
End Su

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

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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
Convert a Number Code to a Text Code Traye Excel Discussion (Misc queries) 3 April 6th 07 09:54 PM
copying vba code to a standard code module 1vagrowr Excel Discussion (Misc queries) 2 November 23rd 05 04:00 PM


All times are GMT +1. The time now is 07:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"