Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default macro code to a shared file

hi,

How can i make this macro code run in a shared file and col M and N are
protected cell.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("K:L")) Is Nothing Then
If Target.Count = 1 Then
If Target.Offset(0, 2) = "" Then Target.Offset(0, 2) = Now
If Target.Column = 12 Then
If Target.Offset(0, 1) = "" Then
Target.Offset(0, 2) = ""
Else
Target.Offset(0, 3) = Now - Target.Offset(0, 1)
End If
End If
End If
End If
Application.EnableEvents = True
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default macro code to a shared file

Hi

You have to unprotect the sheet before you can change it:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
Application.EnableEvents = False
ActiveSheet.Unprotect Password:="JustMe" 'Change to your own password
If Not Application.Intersect(Target, Range("K:L")) Is Nothing Then
If Target.Offset(0, 2) = "" Then Target.Offset(0, 2) = Now
If Target.Column = 12 Then
If Target.Offset(0, 1) = "" Then
Target.Offset(0, 2) = ""
Else
Target.Offset(0, 3) = Now - Target.Offset(0, 1)
End If
End If
End If
ActiveSheet.Protect Password:="JustMe"
Application.EnableEvents = True
End Sub

Hopes this helps.
....
Per


On 10 Aug., 02:59, newbie_010108
wrote:
hi,

How can i make this macro code run in a shared file and col M and N are
protected cell.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("K:L")) Is Nothing Then
If Target.Count = 1 Then
If Target.Offset(0, 2) = "" Then Target.Offset(0, 2) = Now
* * If Target.Column = 12 Then
* * If Target.Offset(0, 1) = "" Then
* * Target.Offset(0, 2) = ""
* * Else
* * Target.Offset(0, 3) = Now - Target.Offset(0, 1)
* * End If
* * End If
End If
End If
Application.EnableEvents = True
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default macro code to a shared file

Hi Jessen,

the cols remain unprotected.

"Per Jessen" wrote:

Hi

You have to unprotect the sheet before you can change it:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
Application.EnableEvents = False
ActiveSheet.Unprotect Password:="JustMe" 'Change to your own password
If Not Application.Intersect(Target, Range("K:L")) Is Nothing Then
If Target.Offset(0, 2) = "" Then Target.Offset(0, 2) = Now
If Target.Column = 12 Then
If Target.Offset(0, 1) = "" Then
Target.Offset(0, 2) = ""
Else
Target.Offset(0, 3) = Now - Target.Offset(0, 1)
End If
End If
End If
ActiveSheet.Protect Password:="JustMe"
Application.EnableEvents = True
End Sub

Hopes this helps.
....
Per


On 10 Aug., 02:59, newbie_010108
wrote:
hi,

How can i make this macro code run in a shared file and col M and N are
protected cell.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("K:L")) Is Nothing Then
If Target.Count = 1 Then
If Target.Offset(0, 2) = "" Then Target.Offset(0, 2) = Now
If Target.Column = 12 Then
If Target.Offset(0, 1) = "" Then
Target.Offset(0, 2) = ""
Else
Target.Offset(0, 3) = Now - Target.Offset(0, 1)
End If
End If
End If
End If
Application.EnableEvents = True
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
if the file is shared, do not execute macro nerohnze Excel Programming 1 January 1st 09 11:46 PM
VB code stalls when file is shared PCLIVE Excel Programming 2 April 15th 08 06:48 PM
VB Code Works Perfect...but Not when the File is Shared TEAM[_4_] Excel Programming 3 September 15th 05 04:55 PM
Macro error when file is shared Eric @ SEASH, Evansville Excel Discussion (Misc queries) 2 August 25th 05 03:26 AM
Shared file - macro error Tom Ogilvy Excel Programming 0 August 15th 03 10:59 PM


All times are GMT +1. The time now is 04:14 PM.

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"