+ Reply to Thread
Results 1 to 54 of 54

Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

  1. #1
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Hello Excel gurus,

    I'm quite new to VBA in Excel and I am working through some steps in a clumsy manner. Things are moving along pretty good so far and I'm excited about all the powerful additional functionality in Excel through the use of VBA.

    Here is my request. When information is entered into a cell, I would like to have the corresponding comment field record a date stamp. If data entered in this cell is changed, I would like to append a new date stamp in the next row of the comment field. So if the cell has been changed 8 times, the comment field would have 8 date and time entries.

    It would be great to see a global solution where all cells are treated in this manner. However, in case the data size bogs down the spreadsheet, could a solution also be provided where a particular column of data would have this option? Additional columns can then be added in the VB code to make them behave the same way.

    Thank you in advance for your help.

    TV

    Edit: Sorry for the late addition but is it possible to record the data being entered into the comment field next to the date? This way a history of values can be seen.
    Last edited by tv69; 11-28-2013 at 01:23 PM.

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    What do you mean by "comment field"? Is it a specific column? or an actual comment added to the cell?
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    By comment field I mean the yellow box that is accessed by right clicking on a cell.

    TV

  4. #4
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    All the cells? That makes it a bit easier.
    Right click on your sheet tab and select View Code.
    Paste this:
    Please Login or Register  to view this content.
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  5. #5
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Please Login or Register  to view this content.
    Last edited by Solus Rankin; 11-28-2013 at 02:09 PM.

  6. #6
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Jacc,

    This works great! Thank you, thank you, thank you. I edited my original post with an additional request to put the cell value entered next to the date in the comment box.

    Did I say thank you already?

    TV

  7. #7
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Hi Solus,

    I pasted the code in a new workbook on sheet1 and it is not working. Did I miss something I had to do?

    Thanks,

    TV

  8. #8
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    my code is set up to work on the entire workbook. It needs to go in the workbook module not a sheet module.

    It also allows you to "edit" multiple ranges without causing an error.

  9. #9
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Quote Originally Posted by Solus Rankin View Post
    my code is set up to work on the entire workbook. It needs to go in the workbook module not a sheet module.

    It also allows you to "edit" multiple ranges without causing an error.
    Ah yes, of course, my newbie qualities are quite evident. There it is in the first line of code calling out Workbook.

    Thanks so much, you guys are awesome!

    How can the cell data being entered also show up next to the date in the comment window?

    Thanks again,

    TV

  10. #10
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Solus, that works really well. I found that the line:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    allows the bypass of the data getting entered into the comment box. If more than one cell is selected and an entry is filled in, one cell receives the entry but does not record the change. Removal of the above line fixes that.

    Thanks again,

    TV

  12. #12
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    You can remove it but what happens when you select more than one cell and delete contents?

  13. #13
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Quote Originally Posted by Solus Rankin View Post
    You can remove it but what happens when you select more than one cell and delete contents?
    Solus,

    Thanks for asking me that question because it does misbehave with an error message 'runtime error 13, type mismatch'.

    I am able to delete more than one cell but the date is not recorded in any of the comment boxes.

    Is there a way to handle multiple cell deletion?

    Thank you,

    TV

  14. #14
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    If cells are deleted would you like them time stamped? or would you like all comments deleted?

  15. #15
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Quote Originally Posted by Solus Rankin View Post
    If cells are deleted would you like them time stamped? or would you like all comments deleted?
    Definitely time stamped. Right now deleting a cell places a blank after the date in the comments and that works out just fine.

    Thank you Solus.

    TV

  16. #16
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    If that is the case I don't think you want them to be able to edit multiple cells. Maybe something like this that sends a message:
    Please Login or Register  to view this content.

  17. #17
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Hi, tv69,

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  18. #18
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Solus,

    That's a nice and simple solution. There's just one little snag, if many cells are selected and delete is pressed, the data is erased and then the new popup you provided shows up.

    Thanks for all your help on this and sorry for the back and forth.

    Cheers,

    TV

  19. #19
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Hi, tv69,

    should not be a problem.

    Please Login or Register  to view this content.
    Ciao,
    Holger

  20. #20
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Quote Originally Posted by HaHoBe View Post
    Hi, tv69,

    should not be a problem.

    Please Login or Register  to view this content.
    Ciao,
    Holger

    Holger,

    Thanks for jumping in, you guys are great. You seem to whip up this code like it's your native language. I hope I can get halfway there someday.

    That works really well but I discovered another way to cheat. If you copy any empty cell and paste into a cell with data and with dates logged in the comment box, the dates in the comment box are cleared and the current time stamp of the pasted cell is entered. I suppose disabling copy and paste from an empty cell to a cell with data would prevent this.

    Thanks so much.

    TV

  21. #21
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Glad to help TV69.

    If you are happy with the solution please mark the thread as [SOLVED] using the thread tools at the top.

  22. #22
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    I have spent some time with this solution and I feel it may need some tweaking. I am trying to do a couple of things that limit the work in the spreadsheet and also cause some things to break.

    First, the solution provided is for an entire workbook. I would like to have this comment timestamp work for one sheet only.

    Second, the comment timestamp works on all fields. Can I instead call out a few columns to have the timestamp applied to.

    Third, I need to insert rows of data via a macro linked to a button. With the code preventing more than one cell being edited, I am prevented also from inserting a new row of data.

    Thank you for your help.

    TV

  23. #23
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    What columns would you like it to be able to affect?

  24. #24
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Hi Solus,

    It will probably be a few columns with data from ranges like A2:A1000, E2:E1000, H2:H1000. I will have a header row and that's my reason for starting at row 2 for each. As I develop the spreadsheet I may need to add more columns.

    Thank you for your help Solus. I really appreciate it.

    TV

  25. #25
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Please Login or Register  to view this content.

  26. #26
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    To add columns that you want to be effected, just add the column number (A = 1, B = 2, etc.) to this line.
    Please Login or Register  to view this content.

  27. #27
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Solus,

    You're awesome! That works great and is so flexible with the column call outs.

    I just need to be able to insert a row of blank data without the error popping up "Please edit one cell at a time, action reverted". I have a macro linked to a button. Clicking the button inserts a new blank row in row 2 (below the header), while incrementing the next order number in cell A2.

    Thanks so much Solus.

    TV

  28. #28
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Please Login or Register  to view this content.

  29. #29
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Hi Solus, that worked great.

    I found another way to bypass and erase the recorded dates in the comment fields. You simply copy a blank cell and paste over a cell with values and the comments in that cell reset and the current time and value are recorded. I have already disabled right click functions.

    I'm also just wondering if you could suggest a good resource to start learning Excel VBA? How long have you been at it?

    Thanks very much Solus.

    TV

  30. #30
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    I've been at it since May. I'm not nearly as talented as some of the senior members of this forum. Here is a thread that has a good list of learning material: http://www.excelforum.com/excel-prog...materials.html

    I learn by doing. So after I read a book (good books help with things you can't learn on your own like "Good" programming practices, such as variable naming conventions, memory usage, etc.) I joined this forum and started to practice by attempting to solve problems.

    Excel help is a good resource also. The hardest part is memorizing all the built in functions that VB has. Its like learning the vocabulary of a foreign language.

  31. #31
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Thanks for the link Solus. I'm diving into much of this and find it's a good way to learn but the syntax always kills me. In addition it's hard to know what function does what without a good resource. Thanks to the internet and forums like this that are so helpful to people starting out.

    In my previous post I was not clear enough and I still have a problem where use of CTRL-C and CTRL-V used to copy/paste into a cell with data results in clearing any previous timestamps. How would you go about preserving existing timestamps in a target copy/paste cell?

    Thank you kindly.

    TV

  32. #32
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    I can't remember if you already have a worksheet_change event. If you do this needs to be placed at the beginning. If not you just need to add it to the sheet module you want it to effect. This will disable ALL methods of pasting to these cells.

    Please Login or Register  to view this content.
    Last edited by Solus Rankin; 12-05-2013 at 12:08 PM.

  33. #33
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Hi Solus,

    Thank you. The new code works but it locks all cells from having data entered, even empty cells.

    TV

  34. #34
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    This has been a long thread with a lot of changes. You might have to post the code as you have it now to refresh my memory.

  35. #35
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Hi Solus, here is the code. Thanks again.

    TV

    Please Login or Register  to view this content.

  36. #36
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    try this instead
    Please Login or Register  to view this content.

  37. #37
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Hi, tv69,

    protect the sheet on opening the workbook to allow macro code to run:
    Please Login or Register  to view this content.
    Alter the name of the sheet to suit your needs.

    As you mentioned before you have a commandbutton on the sheet which should feature the following code (adjust the name of the command, code goes behind the sheet):
    Please Login or Register  to view this content.
    The event itself could look like
    Please Login or Register  to view this content.
    Regarding the copying/cutting: use the SelectionChange-Event to store the comment in a globale string variable and add that after inserting (empty the variable after that).

    Ciao,
    Holger

  38. #38
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Thank you HaHoBe for your input. I think your suggestion for using 'EnableEvents' may fix my current problem but I'm not sure how to implement it so I have provided the code for a 'Submit' Sub I am using.

    Please Login or Register  to view this content.
    I'm getting an error of 'Object doesn't support this property or method'.

    [Note: I've been trying to use the filename without the path to the target workbook. It resides in the same folder as the source workbook. I have not worked that out and thus the superfluous commenting.]


    Thank you Solus once again, your solution to prevent the copying and pasting of cells works just fine. However the current issue is I cannot select an entire row, copy and paste in a new workbook with my code above. My guess is this block of code is preventing that from happening since I am selecting more than one cell.

    Please Login or Register  to view this content.
    Solus, you have touched on it in a previous post in this thread with the Application.EnableEvents function as HaHoBe has mentioned, but again I'm not entirely sure where those commands must go. I have tried a few places with no luck.

    The good news is I am reading Excel VBA for Dummies and much of this is starting to make sense, especially syntax... but I'm obviously still struggling!

    Thanks very much for your help.

    TV
    Last edited by tv69; 12-10-2013 at 12:07 PM.

  39. #39
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    You don't have to select in order to copy. What are you trying to achieve with the SUBMIT code?

  40. #40
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Hi Solus,

    The 'Submit' Sub is meant to transfer an order from the 'Incoming Purchase Order' Workbook to a 'Submit Temp' Workbook. Workbook 'Submit Temp' is really a staging area. Someone from production will then pull orders from the 'Submit Temp' into a 'Production' workbook.

    The 'Incoming Purchase Order' Workbook has a single user 'A' with unique password. The 'Production' Workbook has a single user 'B' with a unique password. The 'Submit Temp' Workbook is meant to work around the passwords and to give Production Control when to pull the info.

    Thanks,

    TV

  41. #41
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    How do you know which order from Incoming Purchase order to copy over?

  42. #42
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Orders submitted will be controlled by user 'A' accessing the 'Incoming Purchase Order'. In my 'Submit' code a time stamp is added in column 13 of a row when submitted. The code also checks if a value exists in column 13, so a row can only be submitted once. The document will be protected and column 13 will be locked. In addition the corresponding comment box will have the time stamp and cell value recorded (as is being done with the initial code you wrote for me).

    There are some funky things happening when combining a protected sheet with the limit of editing one cell at a time in the code you provided. I'm trying to debug and having a bit of trouble. Mind you, all this adds to the VBA programming experience so I don't mind. I don't want to confuse the matter by mentioning these specifics of the funky occurrences right now.

    Thanks Solus,

    TV

  43. #43
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Please Login or Register  to view this content.
    This will do the same thing without conflicting with your code to disable copy and paste. It will also handle any errors caused by missing workbooks. PLEASE NOTE. This will NOT need to be changed for each user. Environ("username") pulls the name of the current user and uses it to find the correct file path.

  44. #44
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Hi, Solus,

    I don´t find it very reliabe to work with either Selection or ActiveCell.

    Ciao,
    Holger
    Last edited by HaHoBe; 12-10-2013 at 02:52 PM.

  45. #45
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    @ Holger

    I totally agree. Thats why I inquired into how the range copied is selected. It didn't seem the OP wanted to go down that rabbit hole so I tried to make do as is.

  46. #46
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Hi Solus,

    What you provided works extremely well with the exception of no time stamp recorded in column 13.

    I added the following code:
    Please Login or Register  to view this content.
    following this line in your code:
    Please Login or Register  to view this content.
    and the date stamp works fine.

    I'm curious to learn from Holger or yourself Solus, why it is not reliable to work with either Selection or ActiveCell?

    Right now the Sub for adding time stamps in comment boxes is disabled. I will enable it and see if it functions as intended.

    In retrospect it was probably more painful to just start with the comment box time stamp and not disclose everything I wanted the workbook to do. As I discovered limitations in the procedure allowing time stamps to be circumvented it did not go very smoothly to try and fix each case while breaking other functions.

    Up until a couple of weeks ago I had always used excel in the most basic of ways and not clearly understood what effects things like protecting a worksheet really have. I'm learning a lot from my mistakes and from your guidance Solus and Holger. My apologies if this is going in a roundabout way and thank you very much for your help and support.

    Cheers,

    TV

  47. #47
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    No worries. Everyone has issues like that. Since most applications of VBA are custom fit it is definitely easier to try to look at the big picture.

  48. #48
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Hi Solus,

    Let me give a quick recap of what I'm trying to achieve here in the hope it makes it clear as to the entire scope.

    1. Click macro button to add a new order row on sheet1 row 2, this is done by copying from a 'template' sheet in the same workbook where cells are pre-formatted. Pre-formatting includes cells with pull down menus, formulas linked to pull down values, and blank cells formatted for date, and order number. A counter increments to generate the next order number and that is also placed in cell 'A2'. The sheet is protected with a password and some of the columns of data are locked.

    This part works really well right now and here is the code I'm using.
    Please Login or Register  to view this content.
    2. On top of this I would like to add the time stamps to specific columns of data and this where your code comes in. I'm currently commenting it out because it's causing errors when the new order macro above is run.

    Please Login or Register  to view this content.
    The problem is it will not let me add a new row when the Sub New_Order() is being run. It returns a Run-time error '1004' Insert method of Range class failed and fails at this line in the 'Sub New_Order()' code:
    Please Login or Register  to view this content.
    When I was able to bypass this error I then ended up with another error caused by this part of the code:
    Please Login or Register  to view this content.
    3. Well if that is not enough, then this code that was introduced to prevent copying and pasting on top of cells with time stamps, effectively losing the history of time stamps, causes another error with the 'Sub New_Order()' code.

    Please Login or Register  to view this content.
    It causes formatting to be messed up and formulae to disappear when the insertion of the new row takes place.

    My apologies for the long post but I should have provided more context in the first post of this thread.

    Thanks once again Solus.

    TV

  49. #49
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    I will take a look at this data when I get home and see if we can come up with a viable solution.

    Food for thought, if you protect the sheet by:
    Please Login or Register  to view this content.
    the sheet will be protected from editing manually but you will still be able to edit it through code. This will prevent you from needing multiple Sheet.Protect and Sheet.Unprotect lines.

  50. #50
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    I'm learning so much!

    Thank a whole bunch Solus.

    TV

  51. #51
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    The sheets are protected? How is a user supposed to edit them anyway?

    The won't be able to copy and paste on a protected sheet, nor will they be able to change cells. Therefore no comments will be added.

    Is there anyway you can attach your workbook as an example? From the code I think I can discern the direction you'd like to go, but it would be nice to have all the details.

    To attach your workbook, click the 'Go Advanced' button below and use the paperclip in the toolbar to navigate to your workbook.
    Last edited by Solus Rankin; 12-12-2013 at 06:16 PM.

  52. #52
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Solus,

    Yes the sheets are protected. I scoured the net to figure out how to pull it off and it seems to be working well so far. Perhaps you are right though and the comment box time stamps won't work as desired with my protection settings.

    I don't have access to the spreadsheet right now but I can send it to you in the morning.

    When sheet protection is set with password, the only ticked boxes are:
    select unlocked cells
    format cells
    format rows
    sort
    use auto filter

    I have two sheets in my workbook. All data is entered on 'Sheet1'. I also have a 'Template' that has the same layout as 'Sheet1'. The 'Template' sheet only includes the heading row and one blank row in row 2. This row 2 although appearing blank has all the goodies that includes drop down lists, formulae activated by drop down list selections, blank cells for other data entry such as dates, and all formatting for cells including justifications, word wraps, categories, and whether cells are locked and hidden.

    In this row 2 Any cells with formulae are locked and hidden. With sheet protection settings set the way specified, these cells cannot even be selected.

    Also in this row 2 cells with drop down lists or cells that required dates and other data to be filled in are not locked and not hidden. These cells are fully accessible when sheet protection is activated. The time stamp in the comment box will record changes to these cells. In my tests when things were not breaking, the cells with formulae do not record time stamps since the values are calculated. It is not necessary but out of curiosity I wonder if it is possible to record values calculated by formulae as an event that can be tracked.

    Activating sheet protection allows access to cells as outlined but sorting was still non existent. Protection settings say that sorting is allowed yet impossible. What's going on?

    Three things have to come together to give the full sorting capabilities with a protected sheet. The trick is to not allow 'Select locked cells' in the sheet protection, combined with "Allow Users to Edit Ranges" in the 'Review/Changes' of the ribbon. You can set an editable range (I selected the entire sheet) and even apply a password for access to this editable range (I did not set a password). You could also assign permissions to groups or users to access this editable range. Next you must activate the "Filter" tool found in the 'Data/Sort & Filter' part of the ribbon which places little drop down selections on the right side of each column heading for filtering options. The combination of setting a range to "Allow Users To Edit Ranges" along with the "Filter" activated means that you can now also use the filter function to sort from largest to smallest or smallest to largest with sheet protection enabled. Sorting from largest to smallest or smallest to largest is not available without setting an editable range. There may be other features not otherwise available but I have not delved into them. Protecting the sheet with the above mentioned settings while ensuring not to tick the "Select locked cells" setting (this setting is at the top of the list of options after pressing the 'Protect Sheet' button) and making sure to tick the "Sort" and "Use AutoFilter" settings below, will give you the most flexibility for sorting.

    In short, the three steps necessary to have full sorting functionality on a protected sheet are:
    1. under 'Review/Changes/Allow Users to Edit Ranges' set editable range (with a secondary password if desired or with group/user rights)
    2. under 'Data/Sort & Filter' activate the 'Filter' tool to allow for filtering options via drop down selections in each column heading
    3. under 'Review/Changes/Protect Sheet' do not allow selection of locked cells in the sheet protection dialog box (do not tick box "Select locked cells") and tick "Sort" and "Use AutoFilter"

    With the settings I have specified, it is impossible to insert a new row. Anytime a sheet is protected and a row or column has even one locked cell in it, it is impossible to insert or delete even if those functions are enabled in the sheet protection settings. In fact it is impossible to even select a row/column under these circumstances if a single locked cell is present. Only if the entire row/column has non locked cells are they selectable with the ability to Insert/Delete a Row/Column.

    Despite this, my workaround is to turn off sheet protection, make the change, and reapply the sheet protection all via VBA. I also did this in a couple of areas of the comment box time stamp to make it work. Is there any harm in doing so? It's a workaround that seems seamless right now but maybe it can be breached between the interval when protection is off and then back on?

    As mentioned in my previous post, with your current code for the comment box time stamp, a new row or New Order can not be inserted in the worksheet. It's a double whammy too because I believe the portion that prevents more than one cell from being edited for the comment box time stamp also prevents a new row from being inserted.

    I hope what I have described above about sheet protection might be helpful to you and others. It all came together from many, many searches over the past couple of weeks with the "Allow Users to Edit Ranges" being the last piece in the puzzle, allowing full sorting functionality via filters.

    Regards,

    TV


    Quote Originally Posted by Solus Rankin View Post
    The sheets are protected? How is a user supposed to edit them anyway?

    The won't be able to copy and paste on a protected sheet, nor will they be able to change cells. Therefore no comments will be added.

    Is there anyway you can attach your workbook as an example? From the code I think I can discern the direction you'd like to go, but it would be nice to have all the details.

    To attach your workbook, click the 'Go Advanced' button below and use the paperclip in the toolbar to navigate to your workbook.

  53. #53
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    I believe what would benefit you the most for your project would be a well put together userform. I think this will make things a lot easier on you and still maintain the efficiencies you've gained for you team. If you are able to gain access to the file and post it, I would like to look at it and give an example of a userform that would suit.

  54. #54
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: Timestamp Entered Into Comment Field Whenever Corresponding Cell Changes

    Hi Solus,

    I'm open to any suggestions you may have.

    I have attached the document. All passwords have been set to "solus".

    Cheers,

    TV
    Attached Files Attached Files

+ 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. Add timestamp to comment upon comment creation (Excel 2007)
    By Shadyhaxx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-30-2013, 12:58 PM
  2. Lock specific cells in row after timestamp entered into another cell in same row
    By sbowden in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-25-2013, 07:21 PM
  3. Replies: 10
    Last Post: 10-07-2012, 04:50 PM
  4. [SOLVED] How do i timestamp comment fields
    By BenMetz in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-15-2005, 12:05 AM
  5. Replies: 1
    Last Post: 06-03-2005, 07:05 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