Forum Discussion
Jon_Big
Sep 07, 2023Copper Contributor
Automatically adding a timestamp after a pulldown is selected
I have been trying to research this myself and I thought I found the solution, but I am still stuck. I have a spreadsheet that has several columns with pull down menus for example Column P. Next to...
HansVogelaar
Sep 08, 2023MVP
Since you didn't include the column headers in the screenshot, I cannot see which cells are involved.
Jon_Big
Sep 08, 2023Copper Contributor
Sorry, the Rev Req Y/n is Column P, and the Review decision date is column Q. Column P is a pulldown to select yes or no. I need the date to show up next to it in Column Q when something is selected.
This is the first set of columns I am doing this for. I have other columns with pull down menus that have more options and I need it to record the date and time each time a new option is selected.
Thanks.
This is the first set of columns I am doing this for. I have other columns with pull down menus that have more options and I need it to record the date and time each time a new option is selected.
Thanks.
- HansVogelaarSep 08, 2023MVP
You now have two Worksheet_Change event procedures. That causes a conflict.
Delete the first one, and insert the keyword Private followed by a space before the second Sub.
Press Ctrl+G to activate the Immediate window.
Type (or copy/paste) the line
Application.EnableEvents = True
With the insertion point anywhere in that line, press Enter.
Now switch back to Excel and select something from a drop-down in cell P2 (or below).
- Jon_BigSep 08, 2023Copper ContributorOk, now we are getting somewhere. I am not exactly sure how it worked, but it works. Now the next step. Can I just duplicate the code and change the values to the next set of columns I need the dates for? Or, do I have to change more details so it sees it as a separate code to run. The next set of columns are R/S. I will also need the code to work for columns U/V and W/X respectively.
Thanks for all your help. You are a life saver.- HansVogelaarSep 08, 2023MVP
You can add the ranges to the code:
Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Range("P2:P670,R2:R670,U2:U670,W2:W670")) Is Nothing Then Application.ScreenUpdating = False Application.EnableEvents = False Intersect(Target, Range("P2:P670,R2:R670,U2:U670,W2:W670")).Offset(0, 1).Value = Now Application.EnableEvents = True Application.ScreenUpdating = True End If End SubPlease note that I changed Offset(1, 0) to Offset(0, 1) to make the code add the date/time in the cell to the right.