Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 440
Default Code needs tweaking :P

Hi
The following code will automatically insert username, date and time when
data is put into 'B' somewhe

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Me.Range("B4:B50")) Is Nothing Then
With Target
If .Value < "" Then
.Offset(0, 8).Value = (UserName)
.Offset(0, 10).Value = Format(Now, "hh:mm:ss")
.Offset(0, 9).Value = Format(Date, "dd/mmm")
End If
End With
End If
End Sub

However, when data is removed from 'B', a debug window appears and the
username etc isn't removed.
If poss, i'd like two versions of this code, the first:
if data is deleted from 'B' username etc is removed too, and
if data is deleted from 'B' username etc remains and is not overwritten

tia,
--
Traa Dy Liooar

Jock
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Code needs tweaking :P

It does debug for me, it works fine, although it doesn't add a username
because the code is incomplete.

This clears it if B blanked

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False

If Not Intersect(Target, Me.Range("B4:B50")) Is Nothing Then
With Target
If .Value < "" Then
.Offset(0, 8).Value = Environ("UserName")
.Offset(0, 10).Value = Format(Now, "hh:mm:ss")
.Offset(0, 9).Value = Format(Date, "dd/mmm")
Else
.Offset(0, 8).Value = ""
.Offset(0, 10).Value = ""
.Offset(0, 9).Value = ""
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub




--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Jock" wrote in message
...
Hi
The following code will automatically insert username, date and time when
data is put into 'B' somewhe

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Me.Range("B4:B50")) Is Nothing Then
With Target
If .Value < "" Then
.Offset(0, 8).Value = (UserName)
.Offset(0, 10).Value = Format(Now, "hh:mm:ss")
.Offset(0, 9).Value = Format(Date, "dd/mmm")
End If
End With
End If
End Sub

However, when data is removed from 'B', a debug window appears and the
username etc isn't removed.
If poss, i'd like two versions of this code, the first:
if data is deleted from 'B' username etc is removed too, and
if data is deleted from 'B' username etc remains and is not overwritten

tia,
--
Traa Dy Liooar

Jock



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 440
Default Code needs tweaking :P

Great, thanks Bob.
--
Traa Dy Liooar

Jock


"Bob Phillips" wrote:

It does debug for me, it works fine, although it doesn't add a username
because the code is incomplete.

This clears it if B blanked

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False

If Not Intersect(Target, Me.Range("B4:B50")) Is Nothing Then
With Target
If .Value < "" Then
.Offset(0, 8).Value = Environ("UserName")
.Offset(0, 10).Value = Format(Now, "hh:mm:ss")
.Offset(0, 9).Value = Format(Date, "dd/mmm")
Else
.Offset(0, 8).Value = ""
.Offset(0, 10).Value = ""
.Offset(0, 9).Value = ""
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub




--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Jock" wrote in message
...
Hi
The following code will automatically insert username, date and time when
data is put into 'B' somewhe

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Me.Range("B4:B50")) Is Nothing Then
With Target
If .Value < "" Then
.Offset(0, 8).Value = (UserName)
.Offset(0, 10).Value = Format(Now, "hh:mm:ss")
.Offset(0, 9).Value = Format(Date, "dd/mmm")
End If
End With
End If
End Sub

However, when data is removed from 'B', a debug window appears and the
username etc isn't removed.
If poss, i'd like two versions of this code, the first:
if data is deleted from 'B' username etc is removed too, and
if data is deleted from 'B' username etc remains and is not overwritten

tia,
--
Traa Dy Liooar

Jock




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
Tweaking Code Richard Excel Programming 3 February 25th 06 07:15 PM
Tweaking Code Richard Excel Programming 2 February 25th 06 02:23 AM
Need help - track changes code needs tweaking purpleme3 Excel Programming 0 December 13th 05 11:46 PM
Tweaking Code - Experts Only! Gordon Excel Programming 4 August 6th 04 04:09 PM
combining 2+ wkbks into 1. Code needs tweaking please ian123[_31_] Excel Programming 12 January 3rd 04 11:20 PM


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