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!
 

Some videos you may like

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,956
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
53,746
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
53,746
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/
 

Watch MrExcel Video

Forum statistics

Threads
1,102,872
Messages
5,489,428
Members
407,687
Latest member
NeoSez

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top