简体   繁体   中英

Looking for Formula or VBA in Excel 2010 to enter today's date and freeze it

I did a search and did not find an exact answer to this question.

I've got a spreadsheet going where I enter data into a row and date it. This is just a price analysis spreadsheet in a game I play, and I'm trying to find the lowest price items are offered for within the period of time I've decided to look at the prices. I'll later use this information to make decisions about what consists of a good price for an item I want to buy or what to charge for an item I want to sell. I enter a set of information about an item, the price, and where and when I found the price.

The data that I put into the row consists of the item name, type of item (within a set of types), the price, the number of days left that the item will be in the "store," and the date that I found the information. When I find an item I've already logged at a lower price than currently displayed, I change the existing line to give the new price and change the date to the current date, the date I found the lower price.

What I want to happen is that when I enter or change data in a particular row in the table the date changes to today's date without me having to manually type today's date. I'm hoping to make the data entry less time consuming. But I don't want Excel to recalculate the date every time I open the spreadsheet, changing the date to the current date. I want the original date entered to stay the same unless I update the row. I'm not good enough with formulas or VBA to figure this out myself. Can someone please make a suggestion?

Thank you in advance for any help you can give.

Here is a very simple worksheet change event you can paste under your worksheet

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
Sheets(1).Cells(Target.Row, 3).Value = Now()
Application.EnableEvents = True

End Sub

You can change the sheet index to whatever sheet you want the date on, and column number (3 in above example) to whatever columnnumber you want the date in.

Good luck with it.

Simplest is probably:

Ctrl + :

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM