+ Reply to Thread
Results 1 to 9 of 9

Timestamp Doesn't Work When Workbook Is Shared

  1. #1
    Registered User
    Join Date
    06-04-2014
    Posts
    13

    Timestamp Doesn't Work When Workbook Is Shared

    Hi;

    I am using a Timestamp which works fine when I don't have the workbook shared, though when I share the workbook, which I want to do it gives me Runtime Error 1004.

    Here is the code I am using;

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 2 Then
    Cells(Target.Row, 3).Value = Time
    End If
    Sheets("Days A").Protect UserInterfaceOnly:=True
    End Sub


    Any help is very much appriciated.

    Kind Regards;

    Anaky

  2. #2
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Timestamp Doesn't Work When Workbook Is Shared

    Can you post an actual example??


    Just FYI,

    One logical bug I've made myself with worksheet change is the "what if the change covers more than one cell?" kind of error. For instance, you code will probably work if the user selects one cell and makes a change.

    But what if they select a bunch of cells and press delete (for instance). If the "Target" passed in is a range of cells then "Target.column" or "Target.Row" will no longer work.

    Is there any change the worksheet protection is to blame? I notice you have a line to protect, but no line at the beginning to un-protect the sheet prior to writing in the third column.
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  3. #3
    Registered User
    Join Date
    06-04-2014
    Posts
    13

    Re: Timestamp Doesn't Work When Workbook Is Shared

    Here is the spreadsheet I am using;

    \1

    When I enter something in Column A or B it gives me this Error, all other cells I have locked for editing.

    I think I might have to add an extra line of code to it so it allows the Macro to run when Shared, I don't know though.

    Thankyou;

    Anaky
    Last edited by Anaky; 08-13-2014 at 04:40 PM.

  4. #4
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Timestamp Doesn't Work When Workbook Is Shared

    Sorry, when asking for an example, I meant a spreadsheet and not a picture of one Also, please use the upload file option that is available when you press "Go Advanced" instead of linking to another location.

    BTW, if the error is happening when you enter a value into a single cell in column A - then there must be something wrong with the .protect() part (because the IF would be bypassed as the target.column would evaluate to 1).


    Why do you need to protect via a macro, when the macro did not unlock anything? Seems strange - I would suggest removing that line

  5. #5
    Registered User
    Join Date
    06-04-2014
    Posts
    13

    Re: Timestamp Doesn't Work When Workbook Is Shared

    New Test Gunstore Issue Log.xlsm

    Sorry, here is the file without any code to it at all.

    Thanks Again

  6. #6
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Timestamp Doesn't Work When Workbook Is Shared

    Ok, I have a few suggestions.

    First, the code needed to have some alterations to handle changes to lots of rows at once. Instead of just checking for the "Target" column, find the intersection of "Target" and Column B. This is more precisely what you want to do (I think).

    Also, don't hard-code values! I used some named constants at the top of the module (where they will always be easy to find) to allow for easy editing. This is a good habit to get into.

    When you use a worksheet change event (that causes another change to be made) turn off events! Otherwise it will want to run again... it's just sloppy. You can turn the events back on prior to End Sub.

    Also, the way your sheet was set up people could alter the tab names - like "Days B". To avoid having that mess up your code, use code names which you can only alter in the VBA editor (you'll see what i mean if you view the object explorer on this workbook).

    :D

    Please have a look at the attachment.


    CODE FOR CHANGE EVENT (I put this in "Days B" - try it out):

    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    06-04-2014
    Posts
    13

    Re: Timestamp Doesn't Work When Workbook Is Shared

    Hi again;

    Sorry it did the same thing again, when I go to share the workbook the timestamp doesn't work.

    Also I don't really understand much you are saying as im very new to VBA. The person that was good with VBA left the company and im trying to make alterations.

    I appreciate your help though greatly, and would like to donate a small fee (if thats possible) if the code worked for me.

    Thanks

  8. #8
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Timestamp Doesn't Work When Workbook Is Shared

    I'm not sure what to tell you. You mean, when you open the workbook it does what it's meant to and when someone else does it gives a 'stack overflow' error?

    Are they opening the file from another computer, or logged in as a different user, or over the network? Not sure what you mean by "share the workbook".

  9. #9
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Timestamp Doesn't Work When Workbook Is Shared

    you can't change the protection in a shared workbook
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  10. #10
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Timestamp Doesn't Work When Workbook Is Shared

    If that is the case I suggest you figure out a different way to "share" the workbook.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] date & Timestamp for row on Protected & Shared workbook
    By Webbers in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-29-2013, 10:42 AM
  2. [SOLVED] Macro work in personal workbook, doesn't work in other workbooks
    By Centexcel in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-30-2013, 11:47 AM
  3. Replies: 0
    Last Post: 09-18-2012, 11:24 AM
  4. Macro doesn't work when shared
    By rasmus1166 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-10-2011, 10:00 AM
  5. When a timestamp doesn't behave as a timestamp
    By mredekopp in forum Excel General
    Replies: 3
    Last Post: 03-07-2011, 03:39 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1