Put number and autocomplete to nearest date?

Magnamuz

New Member
Joined
Oct 8, 2019
Messages
2
Hi, part of my job is to put dates to documents that were made in the past 15 days or so, and I'd like to know if there's a way to put, for example, if today is 08/10/2019, then I'd put a 4 and it should assume that I want to put 04/10/2019, or a 26 and it should assume that is 26/09/2019 (from last month, obviously). For the moment it autocompletes to xx/01/1990... :(

Thanks!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
32,151
Office Version
365
Platform
Windows
Hi & welcome to MrExcel.
You could use a formula in another cell like
=DATE(YEAR(TODAY()),MONTH(TODAY())-IF(D2>DAY(TODAY()),1,0),D2)

Where D2 is the cell with the number.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
51,461
Office Version
365
Platform
Windows
Welcome to the Board!

It is important to understand how dates work in Excel. Dates are actually stored as numbers in Excel, specifically the number of days since January 0, 1900. They just then have a date format applied to them to look that way.
You can see this easily by going to any valid date in Excel, and changing the format to "General". Then you will see the date as Excel does (the number of days since January 0, 1900).

So, if you enter a 4, on cell with date format dd/mm/yyyy, it will return 04/01/1900.

Without the use of a helper cell, I think in order to do what you want, you would need to apply some VBA. If that is something you would be interested in, please let us know and provide more details, such as what is the cut-off/criteria for determining whether it should be this month or last month.
 
Last edited:

Magnamuz

New Member
Joined
Oct 8, 2019
Messages
2
Without the use of a helper cell, I think in order to do what you want, you would need to apply some VBA. If that is something you would be interested in, please let us know and provide more details, such as what is the cut-off/criteria for determining whether it should be this month or last month.
I don't know what a VBA is, sorry.

The idea is to fill in a table for the internal-quality sector that asks for a form with several dates, such as document starting date, completion date, processed date, etc. So I have to put 01/10/2019, 03/10/2019 and 08/10/2019 in several columns, without formulas in those columns.

And the criteria for choosing the month would be to put a day that hasn’t come yet, for example, if today is 08/10/2019 and I put the number 12, then it should assume that I mean 12/09/2019 cause 12/10/2019 hasn’t come yet (assuming excel can check the current date, obviously).

I suppose I was looking for an internal way to do this, not a formula cause I'll be needing other columns to do this. As it was said, it counts from 01/01/1900 onwards and I'd like it to count down from current date instead, somehow, now I'm not thinking it's possible...

Thanks for the answers so far.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
51,461
Office Version
365
Platform
Windows
If I understand you correctly, I think what you are talking about requires the use of VBA (background code that runs when we want it to) or "helper" formulas, as Fluff suggested, as you are asking Excel to behave in a way that is different than it was designed to do.

If the sole purpose is to save a few keystrokes, so that the user only has to enter one number instead of a full date, consider adding a Date Picker instead.
See: https://www.ablebits.com/office-addins-blog/2016/10/12/insert-calendar-excel-datepicker-template/
 

Forum statistics

Threads
1,081,860
Messages
5,361,737
Members
400,653
Latest member
ProParadox

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top