If / Then In A Macro - Changing 2 Digit Year Into 4 Digit Year

Jul 3, 2014

I need a macro where I can highlight a column and change all of the 2 digit years to a 4 digit year (actually, some of the 2 digit years are only 1 digit, e.g. "9" instead of "09").

I have an if then statement that I can use in the column after it, but I'd rather change the actual numbers in the original column, rather than adding another column (and having to keep the original, too).

The statement I had was:
=if(A1>=50,1900+A1,2000+A1)

I just copy dragged down to get the cell numbers for the rest of the column... but using A1 was just for an example, here, it's not necessarily going to be in that column. It needs to be just whichever cells I select.

It seems like it should be pretty simple, but I don't know how to word it in a macro.

Starting Column Example:
12

13

14

99

11

[Code] ......

For some reason I can't get rid of the borders...

View 6 Replies


ADVERTISEMENT

Converting 2 Digit Year Into 4 Digit Year

Apr 15, 2008

I have 2 digit years (98, 99, 00, 01) that I need to convert to 4 digit years (1998, 1999, 2000, 2001). There is one year per cell. If it was simply a matter of adding 19 or 20 to the beginning of each, I could do that. But since there's a combination of both 19 and 20 that needs to be added and there all intermingled, I'm not sure how to do it.

Can a rule be written to add 19 to the beginning except if the current cell starts with a 0, then add 20? The highest year is 2008 (no 2010 to deal with).

Example:

98 --> 1998
99 --> 1999
00 --> 2000
01 --> 2001

View 9 Replies View Related

Two Digit Year Changes On Import

May 31, 2006

I am importing data from a .csv file. The file contains dates like 02/15/40. The year is 2040, not 1940. Excel doesn't seem to use the Control Panel -> Regional Settings change when I open this file. I have my Regional Settings set to 2000 => 2099 to change to a two digit year. If I open a blank worksheet and type in 2/15/40 in a cell...Excel does the correct conversion to 2040. However, when I open a .csv file it considers it 1940.

View 2 Replies View Related

Extract 4 Digit Year From String?

Aug 5, 2013

So I want to extract the four digit year found in several strings, for example:

A1: Toyota Camry 1997 Replacement Engine ...

In b1 I'd like to return: 1997 ...

View 7 Replies View Related

Check 4 Digit Fiscal Year Is Entered In A Cell

May 6, 2009

This is my code. It is for checking that only a 4 digit fiscal year is entered in a cell. The code works fine except it only checks a max of three time. So if the user enters xxx it will prompt for a correct response three times, if xxx is entere a 4th time then that value appears in the cell. I was wondering why this is taking place.

Here is my

View 7 Replies View Related

Number Store As Text & Text Date With 2 Digit Year

Dec 23, 2008

I have a macro which will import data to the worksheet, then perform some formatting on the data, then assign the month & job description based on the lookup table. The problem is that when I import in the data, the data in column B&C will be store as text instead of number and the date in column E will store a 2 digit year instead on 4 digit year which cause error to my macro. I have try to preset the column format to number, i even try to change the column format to number when i run the format macro data. But the problem is still there.

View 5 Replies View Related

Seperate 2 Digit Number Into 2 Single Digit Numbers

Apr 3, 2008

I know you can take a number from one cell and combine it with number from another cell and make it one number. What I need to do is the reverse. Take a two digit number in a cell and separate it into single digits in two cells. If you have the number 50 in a cell, then is there a formula that will take the 5 and put it in cell and take the 0 and put it in the cell beside it?

View 4 Replies View Related

Check Digit For 8 Digit Number

Jun 13, 2014

How to calculate a check digit in excel. The details to calculate this are as follows:

All variables in the calculation are positive integers.

We take each integer of the pro number and multiply it by a value and sum them to get a total.

An Example: 8 Digit Pro Number: 66988757
Pro Number: 6 6 9 8 8 7 5 7
Position in the Pro Number: 1 2 3 4 5 6 7 8
Multiply each digit in the pro number by (10-position) in the number, to achieve a sum.

Using our example pro again:
6*(10-1) + 6*(10-2) + 9*(10-3) + 8*(10-4) + 8*(10-5) + 7*(10-6) + 5*(10-7) + 7*(10-8)
6*9 + 6*8 + 9*7 + 8*6 + 8*5 + 7*4 + 5*3 + 7*2
54+ 48+ 63+48+40+28+15+14 = 310
Take the Sum of the previous calculation and divide it by 11
310/11 = 28

(Actually, it's 28.181818, but since we're working with integers, we truncate everything behind the decimal).

Figure a remainder by multiplying the quotient by 11 and subtracting from the sum.
Remainder = 310 - (28*11) ---> Remainder = 310 - 308 ----> Remainder = 2
Check Digit = 11- Remainder
Check Digit = 11 - 2 ---> Check Digit = 9
Note: if the check digit is 10 or 11, need to subtract 10 from the Check Digit.

View 3 Replies View Related

Remove The Last Digit From Each Number, Turning It Into A 5 Digit Number

Mar 2, 2009

I have a column of 6 digit numbers in excel, and I need to remove the last digit from each number, turning it into a 5 digit number. No rounding, just simply remove the last digit. Each number is different. Does anyone know how to quickly and efficiently remove the last digit from each number? I can convert to alphanumeric string if need be...

View 4 Replies View Related

Message To Apear It The User Selects A Year AND Month Less Than The Current Year

Sep 25, 2006

I have two combo boxes: One for entering the Year, and one for the month. I can produce a message if the user leaves either box blank but I want a message to apear it the user selects a year AND month less than the current year (iYear) and current month (iMonth). I therefore need an AND statement between the two criteria but i dont know how to do it.

'....First Checks the Comboboxes arent blank then below Checks a future month/year secection is chosen

ElseIf YearBox.Value = iYear & iMonthbox < iMonth Then
MsgBox ("You may not enter Data before the current Month")
Else '...... Run main code here

View 3 Replies View Related

Formula To Compare Previous Year To Current Year

Dec 8, 2013

Looking for a formula to compare current year values to previous year values. For example, if the current year has values for the month of January through March (100, 100 and 150), current year value will be 350 and the previous year value will be 975 (i.e. 300+275+400). The aim here is to make the previous year months summation equal to the present (or current) values. As new values are entered for the current year, the previous year's values will have to change to reflect the new month's value entered for the current year.

Month 2012 2013
Jan 300 100
Feb 275 100
Mar 400 150
April 650
May 454
June 800
July 500
Aug 375
Sep 525
Oct. 300
Nov 410
Dec 510

Sample file is attached : Comparison_Years.2011.xls‎

View 4 Replies View Related

Change Year But Keep Month The Same Based On Current Year

Mar 8, 2014

I am working on a budget for myself and want it to have running dates so the first data column will have the current month. I was able to succeed with this using the EOMONTH function followed by EDATE functions in the following cells, I then have these columns filled using a nested VLOOKUP MATCH function pair.

The problem I run into is with the months that extend into the next year, in my data table I have month by month listed started on 01/01/2014 ending 12/01/2014 but as soon as the month is no longer January the last column in my budget cannot find the information needed due to it looking for 2015. so what I would like to know is if there is a way to make the data table change the year to the following year after today is beyond that month, so for example on March 1 2014 both January and February would be changed to 2015.

Attached is an example : Budget Example.xlsx‎

View 4 Replies View Related

Date And Month From A Column And Year Should Take Current Year

May 14, 2009

I have dates in my column “A”, for example (A1 cell =22-Mar-1971), (A2 cell=30-Dec-1965). Now my requirement is in B column date and month from A column and year should take current year. Output in B column (B1 cell =22-Mar-2009), (B2 cell=30-Dec-2009)

View 3 Replies View Related

Changing The Year

Jul 4, 2008

In my sheet I have a cell that has the year in 4 digits plus 5 other digits for incidents in our fire dept. (ie 2008#####) what I want is to have the year automatically change to 2009 on the first day of the new year.

View 9 Replies View Related

Changing Year Automatically

Jan 2, 2012

I have been using the following to change the year in the Header

Code:
Sub Change_Format()
' Ctrl-y will change the year per individual sheet
ActiveSheet.PageSetup.RightHeader = Format(Now(), "YYYY")
End Sub

Is there a way to have this done automatically? There are absout 6 sheets in the workbook that have the year in the header and right now the code is in Module 3 and I have to press ctrl+y for every sheet.

View 4 Replies View Related

Changing Year In VBA Code

Mar 10, 2007

I have VBA code that has the year for embedded within the code for eg "Fixed assets 2007.XLS"

I would to write VBA code that will enable me to change the date from say 2007 to 2008, wherever it appears in a partcular workbook.

View 9 Replies View Related

How To VBA Activecell Value Year Equal To Current Year

Dec 13, 2011

I am trying to do an IF statement, if the activecell's value is equal to this current year, do nothing and if its not the current year, to offset one column to the right and insert a blank column, then copy the whole column to the left and replace it with the new blank column.

View 1 Replies View Related

Look Up The Date To See Which Year It Falls In And Return The Year

Oct 13, 2008

i have the following table of information

Year DOB
7 01.09.96 -31.08.97
8 01.09.95 -31.08.96
9 01.09.94 -31.08.95
10 01.09.93 -31.08.94
11 01.09.92 -31.08.93

and a list of dates i need to look up the date to see which year it falls in and return the year

View 9 Replies View Related

Convert Date From Any Year To Current Year

Feb 27, 2009

DATE function won't return TODAY()'s year in the "year" slot.

Is there a way convert, for example, 2/8/1963 to 2/8/2009 without using Concatenate?

View 9 Replies View Related

Line Chart With Year On Year Comparison

Sep 29, 2006

I know that in order to draw a chart where a data line for a certain period is compared with the same period the previous year, one should have the 2 sets of data of different year side by side columnwise. However, is there a way where I could still churn out the same line chart when the data is all on a single column?

View 9 Replies View Related

Changing Whole Year By Entring Date

May 7, 2008

I have a sheet where column A5 to Axx is filled with date from 01. jan to 31.dec. I.E.
A5= 01.01.2008
A6= 02.01.2008
A7=03.01.2008
etc
etc

Based on comparing the date the sheets collecects data from other sheets. It works fine, but I want the possibility to change the year by entering i.e 2007 in cell A1 and then the sheets change Cell A5 to 01.01.2007. I know i can use replace function manually, but when i want to simulate/compare betwen years it would be very nice to just enter the year and the sheet would collect new data.

View 10 Replies View Related

Changing The Year In Date Range From Another Cell

Feb 22, 2007

I am trying to change the year of a date range I search from.

I have a selection of dates, I use sumproduct on a seperate page to calculate the number of entries between two dates entered in seperate cells

=SUMPRODUCT((HFRA!B4:B2000>=Summary!B1)*(HFRA!B4:B2000<=Summary!B2))

Cell B1 conatins the date 01/01/2007, and cell B2 contains the date 31/01/2007. I repeat this for every month of the year.

I want to be able to change the year of these dates in B1 and B2 from a seperate cell on another page.. so I can change the search ranges to 2008 without going into each cell and changing it manually.

View 9 Replies View Related

Changing Formula To Count Based On Year And Not Month?

Apr 15, 2014

I'm using this formula to count how many times the date in column C and the text "WON" appears in column I and it falls within the month & year that is in Z65.

=COUNTIFS(INDEX(C:C,$AL$15):INDEX(C:C,$AL$17),">="&DATE(YEAR(Z65),MONTH(Z65),1),INDEX(C:C,$AL$15):INDEX(C:C,$AL$17),"

View 2 Replies View Related

Convert 4 Digit Zip Code To 5 Digit Zip Code?

Apr 25, 2014

I have an address (city, state, zip format) in a cell. Some of the zip codes only have a 4-digit zip code which is the way the file was received. I know these zip codes have leading zero. How can I convert these to a five-digit code. Examples are as follows:

Waltham MA 2453
convert to 'Waltham MA 02453'

Boston MA 2210
convert to 'Boston MA 02210'

CEDAR GROVE, NJ 7009-1174
convert to 'CEDAR GROVE, NJ 07009-1174'

TEANECK CITY, NJ 7666
convert to 'TEANECK CITY, NJ 07666'

View 3 Replies View Related

Year Converted Into Decimal Year

Oct 21, 2009

1. I need to convert a year into a decimal year ie. 1830 into decimal year (I don't have a month, just year)

2 Year/month into decimal year/month

I just not sure what to do, is the year stored as a number/text/date. What should it even look like? Does 1830 display as 1830.00 using excel.

View 9 Replies View Related

Add Value From Last Year To Total On This Year In PivotTable

Oct 22, 2007

I'd like to know a formula which can calculate the moving annual total, that is the sum of the last 4 quarters. Now every time the sales from a quarter is known, i have to recalculate the MAT mannually.

View 2 Replies View Related

SUMIF Month & Year: Find Total Cost By Month Only For Year 2009

Dec 17, 2009

In attached sheet, I am trying to find total cost by month only for year 2009. Currently formula I have in Cell c24, is {=SUM(IF(MONTH(B2:B9)=1,D2:D9,0))} But this calculates for all years, not just 2009. How do I modify above formula, so for each month, it shows total cost but only for 2009?

View 2 Replies View Related

Change Total Formulas For All Tables At Once To Show Either Year-to- Date Or Total Year

Oct 15, 2007

I have a sheet in my workbook with at least 180 small tables, there may be more.
I woulds like to be able to change total formulas for all tables at once to show either year-to- date or total year.

For example:
If we have only progressed through the second period of the year, I would like to choose something to indicate period 2. At other time I may want to know the total year whether the periods are completed or not.

View 9 Replies View Related

How To Get Only Month Year If There Is DATE - MONTH - YEAR In A Cell

Aug 20, 2013

How to get only MONTH' YEAR if there is a DATE-MONTH-YEAR in a cell?

A1: 27-July-2012

Answer D1:JULY' 2012

Pl note "' " is suffixed after JULY (the month).

View 4 Replies View Related

Convert Date To Year/week Of Year/day Of Week

Apr 6, 2007

Is it possible to format cells to convert a date format of month/day/year to = year/week #/day of week? For example, 04/05/07 (April 5, 2007) would read as 7145, (7=last digit of year/ 14 = week number / 5 = day of week....Sunday being the first day of week)

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved