making excel recognize it's 20XX not 19XX

daveyc18

Active Member
Joined
Feb 11, 2013
Messages
420
is there a simple way to do this so that it's not PC dependent ? change the settings within the workbook? rather not use formulas
 

Some videos you may like

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

daveyc18

Active Member
Joined
Feb 11, 2013
Messages
420
is there a simple way to do this so that it's not PC dependent ? change the settings within the workbook? rather not use formulas
looks like it needs to a formula of some sort....so im seeking a macro to do that instead
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
52,070
Office Version
365
Platform
Windows
Can you provide some more details of exactly what you are trying to do?
Do you want a macro that automatically makes dates entered into a certain range on a certain sheet year 20xx?
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
35,648
Office Version
2010
Platform
Windows
Can you provide some more details of exactly what you are trying to do?
Do you want a macro that automatically makes dates entered into a certain range on a certain sheet year 20xx?
In addition to Joe4's question above, is there a particular sheet and range that your dates can be in or are you wanting a general fix for any sheet in the workbook inside of any cell on the sheet?
 

daveyc18

Active Member
Joined
Feb 11, 2013
Messages
420
Can you provide some more details of exactly what you are trying to do?
Do you want a macro that automatically makes dates entered into a certain range on a certain sheet year 20xx?
yes exactly ..and
only two columns ...f and g in sheets repo, retail , MBs abs prov , bill , and ba only
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
35,648
Office Version
2010
Platform
Windows
only two columns ...f and g in sheets repo, retail , MBs abs prov , bill , and ba only
Give this workbook event code a try (it will automatically make all date years be in the 2000's when they are entered into a cell in Column F or G on the indicated sheets)...
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
  If Target.CountLarge > 1 Then Exit Sub
  If UBound(Filter(Array("repo", "retail", "MBs abs prov", "bill", "ba"), Sh.Name, True, vbTextCompare)) > -1 Then
    If Target.Column = 6 Or Target.Column = 7 Then
      If Year(Target.Value) < 2000 Then Target.Value = DateAdd("yyyy", 100, Target.Value)
    End If
  End If
End Sub
HOW TO INSTALL Event Code
------------------------------------
If you are new to workbook event code procedures, they are easy to install. Go into the VBA editor (ALT+F11) and look at the small windows to the left... find the one titled "Project-VBA Project" and double-click the entry in it named "ThisWorkbook"... that will open the workbook's code window. This will open up the code window for the workbook. Copy/Paste the above event code into that code window. That's it... the code will now operate automatically whenever a date is entered in Column F or G on any of the indicated worksheets. Note... if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 

daveyc18

Active Member
Joined
Feb 11, 2013
Messages
420
Give this workbook event code a try (it will automatically make all date years be in the 2000's when they are entered into a cell in Column F or G on the indicated sheets)...
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
  If Target.CountLarge > 1 Then Exit Sub
  If UBound(Filter(Array("repo", "retail", "MBs abs prov", "bill", "ba"), Sh.Name, True, vbTextCompare)) > -1 Then
    If Target.Column = 6 Or Target.Column = 7 Then
      If Year(Target.Value) < 2000 Then Target.Value = DateAdd("yyyy", 100, Target.Value)
    End If
  End If
End Sub
HOW TO INSTALL Event Code
------------------------------------
If you are new to workbook event code procedures, they are easy to install. Go into the VBA editor (ALT+F11) and look at the small windows to the left... find the one titled "Project-VBA Project" and double-click the entry in it named "ThisWorkbook"... that will open the workbook's code window. This will open up the code window for the workbook. Copy/Paste the above event code into that code window. That's it... the code will now operate automatically whenever a date is entered in Column F or G on any of the indicated worksheets. Note... if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
thanks let me give this a try
 

daveyc18

Active Member
Joined
Feb 11, 2013
Messages
420
does the trick

jsut fyi....it's no big deal, but the only way I can clear the dates is by highlight both of them then pressing delete (or I delete the entire row).

if i just enter a date in one colum (eg column F) and try to delete the cell , it turns into 12/30/99 (regardless of the date) and I can't delete it. no big deal, but just again fyi.
 
Last edited:

Eric W

MrExcel MVP
Joined
Aug 18, 2015
Messages
9,290
There is a Windows setting to handle this.

Click Control Panel > Time & language > Under "Related settings" on the right: Additional date, time, & regional settings > Change date, time, or number formats > Additional settings > Click the Date tab > and in the Calendar section, scroll the number until it says 2099.

They certainly buried it deep enough.
 

Forum statistics

Threads
1,089,378
Messages
5,407,915
Members
403,171
Latest member
mayesmail12

This Week's Hot Topics

  • help please
    SORRY NOT ANY GOOD AT EXCEL SO HELP WOULD BE MUCH APPRECIATED this formula is in a sheet called ignore...
  • two formulas needed
    Hello, I'll try my best to explain this: First formula needed in Sheet1 cell A2: If Sheet1 cell B2 = Sheet2 cell B2 then return a 1. If not then...
  • Dynamic Counts
    Good afternoon, we are tidying up some data & the data seems to be growing quicker than we are tidying it up! What we confirm (by reviewing it...
  • Help Excel formula eliminate duplicate values and keep only 2 identical rows.
    as picture below column A has a duplicate value. but the values are not the same as the rule. sometimes 4 rows, sometimes 10 rows or 7 or 9...
  • Macro Compile Error Sub or Function not defined
    Hello, I am trying to run macros from a validation list, all macros have been created and run perfectly on there own but I'm getting a compile...
  • Last row combined with Current Region VBA
    I'm generally happy finding the last row of data through something like Lastrow = Cells(Rows.Count, "D").End(xlUp) but I don't always receive data...
Top