+ Reply to Thread
Results 1 to 27 of 27

VBA and Macros / Autopopulating Date Stamp and username

  1. #1
    Registered User
    Join Date
    11-12-2014
    Location
    USA
    MS-Off Ver
    office 2010 and 2013
    Posts
    40

    VBA and Macros / Autopopulating Date Stamp and username

    Greetings All. I need help on an excel project I am working on. I have have no experience in VBA and macros with excel. However, I am a whiz at other things in excel which mainly consist of formulas, pivot charts and tables, and statistical analysis. The current project I am working on is gathering data from multiple people. Granted, using the sharing and track changes feature would probably be the best way to go about doing this. However, the people I am gather data from are inept when it comes to excel. I do not what to have a meeting just to go over how to input data into the spreadsheet, and how to create a audit trail of their changes and additions. Hence why I am diving down the rabbit hole into VBA and Macros. I want to make this workbook and intuitive as possible. It is much easier to tell people to enable macros and have things just happen. LOL

    So this is what I have done and figured out so far. I have figured out how to change the color of the font if someone makes a change to a cell. I have also figured out how to add a date stamp if someone changes a cell or multiple cells in a row. However, I learned this by watching a youtube video. The instructor only had two columns he was working with: Column A (Name) and Column B (Date Updated). When he updated column A, a date stamp populated the corresponding cell in column B. I have 17 columns in my spreadsheet. I also have 433 rows/record, all needing updates and additional information added. So I have the same code written 17 times. So I am hoping someone can tell me how to consolidate the length of the code yet achieve the same results. Also, I am wondering how to get the person's username who is reviewing, editing, and adding information to the spreadsheet to auto populate in Column T. The date stamp is currently auto populated in Column S. Can a line be added to the code to accomplish this? The code I have is below.

    Cheers,
    Kaytie

    ************************************

    Please Login or Register  to view this content.
    Last edited by akaytie; 11-12-2014 at 08:34 PM. Reason: request from moderator

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: VBA and Macros Nightmare / Need help quick!

    Welcome to the forum.

    Please take a few minutes to read the forum rules, amend your thread title accordingly, and edit your post to add CODE tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: VBA and Macros / Autopopulating Date Stamp and username

    Hi and welcome.

    Firstly the moderators are probably going to chase you up over the title and not having your code tagged.

    That aside this is totally untested but have you tried


    Please Login or Register  to view this content.
    Happy with my advice? Click on the * reputation button below

  4. #4
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: VBA and Macros / Autopopulating Date Stamp and username

    I'd use this slight tweak on Crooza's code:

    Please Login or Register  to view this content.
    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  5. #5
    Registered User
    Join Date
    11-12-2014
    Location
    USA
    MS-Off Ver
    office 2010 and 2013
    Posts
    40

    Re: VBA and Macros / Autopopulating Date Stamp and username

    I will try these suggestions when I get back to work and my worksheet tomorrow morning. For the time being I am going to assume both options would work. So this is my followup question. Can anyone tell me how to tweak Trebor76 or Crooza's code further to get a person's username to appear in the column next to the date and time stamp which is Column T? Who ever can give me the answer to this last piece of my puzzle will literally be my hero! ~Kaytie

  6. #6
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: VBA and Macros / Autopopulating Date Stamp and username

    I did this once but I don't have the file handy at present so again this is totally untested but have you simply tried
    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: VBA and Macros / Autopopulating Date Stamp and username

    Hi Kaytie,

    You need to use either the Application.UserName or the Environ("username") methods. There is a good thread describing the differences between the two here.

    I have used the later function below:

    Please Login or Register  to view this content.
    HTH

    Robert

  8. #8
    Registered User
    Join Date
    11-12-2014
    Location
    USA
    MS-Off Ver
    office 2010 and 2013
    Posts
    40

    Re: VBA and Macros / Autopopulating Date Stamp and username

    So Robert let me see if I understand the difference between Application.UserName and the Environ("username") functions. So Environ("username") is the user name which a person logs into Windows with. So if my organization uses employee ID numbers to log on and I use Environ("username"), then Row,20 so populate with the employee ID number? But if I use Application.UserName, Row 20 will populate with the name the employee entered the first time they opened the excel application? Application.UserName can be easily change whereas Environ("username") is not. If this is a correct statement, I think you gave me the right code as have the employee ID populate Row, 20. ~Kaytie

  9. #9
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: VBA and Macros / Autopopulating Date Stamp and username

    So if my organization uses employee ID numbers to log on and I use Environ("username"), then Row,20 so populate with the employee ID number?
    Correct.

    But if I use Application.UserName, Row 20 will populate with the name the employee entered the first time they opened the excel application?
    No, it's the default owner name of Excel - where I work it's my company's name. This can be viewed and changed via the four steps listed here. As it can easily changed (though I doubt many people do) it's not as realiable as using the ENVIRON function but you will need a list of employee ID numbers and their corresponding names for that to be meaningful

    HTH

    Robert
    Last edited by Trebor76; 11-13-2014 at 06:26 AM.

  10. #10
    Registered User
    Join Date
    11-12-2014
    Location
    USA
    MS-Off Ver
    office 2010 and 2013
    Posts
    40

    Re: VBA and Macros / Autopopulating Date Stamp and username

    Wow! This is so awesome! Thanks Robert aka Trebor76 and Crooza. This is exactly what I needed. I just would like one last tweek to the code. I do want the font to change color when a change is made. However, I do not need the font to change color in column S (date stamp), column T (reviewer username), and column U (comments). I just want the font to remain black. Can I get a code fix for that?

    Please Login or Register  to view this content.
    And Robert aka Trebor76 => Employee ID in my organization is very meaningful and very easy to look up. That is exactly what I need in my spreadsheet. Thanks a million!

    ~Kaytie
    Last edited by akaytie; 11-13-2014 at 12:46 PM.

  11. #11
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: VBA and Macros / Autopopulating Date Stamp and username

    Hi Kaytie,

    I'm not too sure what you mean - is it that you the font colour for the entire tab in magenta and just columns S, T and U in black?

    Robert

  12. #12
    Registered User
    Join Date
    11-12-2014
    Location
    USA
    MS-Off Ver
    office 2010 and 2013
    Posts
    40

    Re: VBA and Macros / Autopopulating Date Stamp and username

    I want cells in columns A though Q to change color when a change is made to a cell. All other cells I want to remain black, cells in columns S, T, and U.

  13. #13
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: VBA and Macros / Autopopulating Date Stamp and username

    akaytie

    the code you're using above seems to do exactly what you're requesting and only change the font of the changed cell. I'm not clear what change you're looking for

  14. #14
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: VBA and Macros / Autopopulating Date Stamp and username

    Ok ignore my comment I posted at the same time as you! So you want the whole row to change?

  15. #15
    Registered User
    Join Date
    11-12-2014
    Location
    USA
    MS-Off Ver
    office 2010 and 2013
    Posts
    40

    Re: VBA and Macros / Autopopulating Date Stamp and username

    No, I don't want the whole row to change color. I just want the text to change color in the cell the person is editing/updating. You are right, the code does exactly that. However, when they do edit the information in a cell, the current code automatically populates Column S and T with a date stamp and username. This is what I want. But because this is still a change, the text color of date stamp and username is magenta. Furthermore if the user inputs a comment, when she/he hit enter the text changes from black to magenta. I want the text color of the date stamp (Col S), username (Col T), and comment (Col U) to remain black. Now that I think about it, I think I want the text in Col A to stay black as well regardless of whether or not the user changes the information.

    I hope this explains it a bit better.

    ~Kaytie

  16. #16
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: VBA and Macros / Autopopulating Date Stamp and username

    Hi Kaytie,

    Here's one way:

    Please Login or Register  to view this content.
    HTH

    Robert

  17. #17
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: VBA and Macros / Autopopulating Date Stamp and username

    OK.

    WIth your code above I couldn't replicate the issue you have with column S and T changing colour.

    Try this it will change the colour from B to R

    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    11-12-2014
    Location
    USA
    MS-Off Ver
    office 2010 and 2013
    Posts
    40

    Re: VBA and Macros / Autopopulating Date Stamp and username

    I don't know what I am doing wrong. I think I am putting the code in the wrong place. I clicked on sheet1 and the code window came up. I made sure I selected worksheet the first drop down field. And the second drop down box has the words "selectionchange". I pasted your code into the window. Now every time I click on a cell, move the cursor to the next cell, hit enter, the entire row text changes to magenta from Column A to Q whether or not I actually change the data in the cells. Not what I had in mind. LOL Can you tell me what I am doing wrong? I tried to upload a screen shoot of my VBA editor with no success.

    Kaytie
    Attached Images Attached Images
    Last edited by akaytie; 11-13-2014 at 08:20 PM.

  19. #19
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: VBA and Macros / Autopopulating Date Stamp and username

    Can you upload your actual worksheet? go to advanced and link it as a file. Remove sensitive data if you need to. If you can't I'll send you my version which I just filled with 'x' from Row A to Row R to test

  20. #20
    Registered User
    Join Date
    11-12-2014
    Location
    USA
    MS-Off Ver
    office 2010 and 2013
    Posts
    40

    Re: VBA and Macros / Autopopulating Date Stamp and username

    Maybe this will help. The reason I couldn't attach the screen shot was it was too big.
    ~Kaytie
    Attached Images Attached Images
    Last edited by akaytie; 11-13-2014 at 08:40 PM.

  21. #21
    Registered User
    Join Date
    11-12-2014
    Location
    USA
    MS-Off Ver
    office 2010 and 2013
    Posts
    40

    Cool Re: VBA and Macros / Autopopulating Date Stamp and username

    Here is the excel file too with all the information removed. Not that I think any of this stuff is sensitive but one never knows.
    ~Kaytie

  22. #22
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: VBA and Macros / Autopopulating Date Stamp and username

    OK I tried your spreadsheet.

    It seems to be doing what you asked for. That is its inserting the date and time and username to column S and T and then changing the columns B to R to magenta text but leaving columns A, S and T as black.

    Are you saying

    1. That this isn't working on your machine OR
    2. this is working on your machine but it's not the outcome you wanted?

  23. #23
    Registered User
    Join Date
    11-12-2014
    Location
    USA
    MS-Off Ver
    office 2010 and 2013
    Posts
    40

    Re: VBA and Macros / Autopopulating Date Stamp and username

    It wasn't working on my machine. I had data already entered in the cells. There were approximately 400 records/row. Every time I clicked on a cell, or moved the cursor, the color would change from black to magenta. It did not matter if I attempted to change the data. And when I did click on a cell or move the cursor to another cell it would place a date and time stamp in Column S and my ID in column T even if I did not edit the information in the cell. However, the text color of the date stamp and my ID.

    I don't know if this is a specific computer problem. I don't know if it is a coding issue. But I do know that what I have described is not the outcome I wanted. Maybe it is because I didn't save the file, close it, and then reopen it? I know I did that before I deleted all the records and attached the file to the forum. Could that be it?

    I cannot check the file now as I am at home working on a MAC running office for mac 2008.

    What are your thoughts, Crooza?

    Would someone else care to check the file too?

    Cheers,
    Kaytie

  24. #24
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: VBA and Macros / Autopopulating Date Stamp and username

    OK. I understand now. The code runs everytime you move out of the cell (regardless of whether there is a change). You want to be able to move around without the cells changing.

    Replace your old code with this instead

    Please Login or Register  to view this content.
    Last edited by Crooza; 11-14-2014 at 01:51 AM.

  25. #25
    Registered User
    Join Date
    11-12-2014
    Location
    USA
    MS-Off Ver
    office 2010 and 2013
    Posts
    40

    Re: VBA and Macros / Autopopulating Date Stamp and username

    Oh my Crooza. That almost fixed it! LOL So at least the colors don't change with every click on a cell or when I move to another cell with my cursor. However, when I do change a cell in a row, I do not want the entire row from Columns B to Columns Q to change. So for example, say I change the information in cell H2. I just want the font in H2 to change to magenta. I do not want the font to change throughout the entire row (B2:Q2). The way the code is written, when I do it it "stamps" the row with the date and username. I want these font color of these columns (Columns S & T) to always be black. The code above does that. I want to keep it that way.

    So what do you say, Crooza? One last tweak and then I can mark this problem solved? Anybody else want to weight in? Pretty please with cherry on top. I so want to have this done today!

    Cheers,
    Kaytie

  26. #26
    Registered User
    Join Date
    11-12-2014
    Location
    USA
    MS-Off Ver
    office 2010 and 2013
    Posts
    40

    Re: VBA and Macros / Autopopulating Date Stamp and username

    I cannot believe it! I figured it out. I am doing a little happy dance. And if I could just figure out how to post a happy dance emoticon. Oh, well... this will have to do!

    I can't take all the credit. Crooza you're awesome! Jim882, you are awesome too.

    Final code that works.

    Please Login or Register  to view this content.
    Thanks a millions to all who contributed.

    Cheers,
    Kaytie

  27. #27
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: VBA and Macros / Autopopulating Date Stamp and username

    Great. Glad you worked it out. Well done.

+ 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. New to Macros. Hoping someone could help with some quick VBA
    By patootoe in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-27-2014, 09:33 AM
  2. Excel 2007 Quick Access Tool Bar Problem with Macros
    By andrezmor in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-02-2014, 06:30 AM
  3. Hidden Sheets and running Macros Quick Question
    By swade730 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-08-2013, 09:51 PM
  4. Quick Access Toolbar macros stopped working
    By surfengine in forum Excel General
    Replies: 1
    Last Post: 10-13-2012, 11:02 PM
  5. Replies: 0
    Last Post: 11-10-2011, 05:26 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