How to extract a date number and income from text string with a fixed width

Some­times, our data is com­bined into one string and we want to extract only a piece of infor­ma­tion, which will help us prop­er­ly under­stand our data. 

How to extract a date num­ber and income from text string with a fixed width

Let’s start with extract­ing the date. What is impor­tant in our exam­ple, is that each string of infor­ma­tion is of the same length, i.e. it has got a fixed width. 

Fig. 1 Data of the same string lengths

We can clear­ly see, that the date starts with the eighth sign and has got eight signs itself (mm/dd/yy). If we want to extract a cer­tain piece of infor­ma­tion, we have to use the MID func­tion. First, we have to write A2 in the argu­ment, because our infor­ma­tion is locat­ed in this cell. Then, we write 8 because we start with the eighth sign, and then 8 again because we want to extract eight chars. And we have our for­mu­la (Fig. 2).

=MID(A2,8,8)

Fig. 2 For­mu­la for extract­ing a date

After copy­ing it down, we have the results. It’s impor­tant though, that the MID func­tion, just like all text func­tions, returns results as text. We can see it because each date is aligned to the left. It may be prob­lem­at­ic if we want to do some date oper­a­tions. We can change the text by adding 0 to our for­mu­la. In oth­er words, we can per­form any math­e­mat­i­cal oper­a­tion that won’t change the returned date (Fig. 3). 

=MID(A2,8,8)+0

Fig. 3 Adding 0 to dates

Now, we can see that the val­ues are aligned to the right. It means that Excel treats them like num­bers, i.e. like dates. We can extract Id num­bers the same way. They start with the first sign and have got 6 dig­its in total. We can also use the MID func­tion. First, we select cell A2, then write 1 because it starts from the first sign, then we write 6 because we extract 6 dig­its (Fig. 4).

=MID(A2,1,6)

Fig. 4 MID func­tion for­mu­la for extract­ing Id numbers

As we can see, Excel extract­ed Id num­bers. Since it is text, Excel left the lead­ing zero for us. We can leave Id num­bers as text if it’s impor­tant for us. If it isn’t, we can do the same as with dates, i.e. add zero (Fig. 5). 

=MID(A2,1,6)+0

Fig. 5 Adding 0 to Id numbers

We can see that Id num­bers moved to the right and the lead­ing zero van­ished. The last piece of infor­ma­tion we want to extract is the Income. Income val­ues don’t have a fixed width. But, since it’s the last piece of infor­ma­tion, we can extract more signs than we need. Let’s extract also the dol­lar sign. The dol­lar sign is in the sev­en­teenth posi­tion. We start writ­ing the MID for­mu­la, then we add cell A2, then 17, and then we have to add the num­ber of places we want too extract. Let’s write 10. It’s, in fact, more that we need, how­ev­er it’s not less either. The MID func­tion will extract the infor­ma­tion to the end with­out any errors (Fig. 6). 

=MID(A2,17,10)

Fig. 6 MID func­tion for extract­ing Income

As in our pre­vi­ous for­mu­las, the results are also text. By adding zero, we change the results into numbers.

MID(A2,17,10)+0

Fig. 7 Text into numbers

We can see that now the results are num­bers. How­ev­er, we can see that we lost the dol­lar sign. This is the way Excel con­verts num­bers with dol­lar signs before them. Indeed, the dol­lar sign isn’t impor­tant in our data, so we should start from the eigh­teenth sign (Fig. 8).

Fig. 8 Remov­ing the dol­lar sign

Now, we have only num­bers. If we want to add a cur­ren­cy, we just go to the Home tab, drop down the Gen­er­al bar and select the Cur­ren­cy option (Fig. 9). 

Fig. 9 Adding a currency

When we have our results with zeros at the end, we can remove them by press­ing the Decrease Dec­i­mal option (Fig. 10).

Fig. 10 Remov­ing zeros at the end

https://www.youtube.com/watch?v=O39qM233-68

Number of Fridays between two dates

Some­times, we want to count a cer­tain num­ber of week­days between two dates. If we want to count work­days, we need to use the NETWORKDAYS func­tion. But, if we want to count the num­ber of, let’s say Fri­days, we have to use the NETWORKDAYS.INTL func­tion. We start with the start date, fin­ish with the end day, and then we mod­i­fy week­ends. In the Excel help descrip­tion, we can see that we can change work­ing days and days off using a text string of 1s and 0s, where 1 means a day off and 0 means a work­ing day. So, Mon­day, Tues­day, Wednes­day, Thurs­day are 1, Fri­day is 0, Sat­ur­day and Sun­day are 1 (Fig. 1).

Num­ber of Fri­days between two dates

=NETWORKDAYS.INTL(A2,B2,“1111011”)

NETWORKDAYS.INTL function
Fig. 1 NETWORKDAYS.INTL function

Here, we have the num­ber of Fri­days between two dates. It’s impor­tant that the func­tion also con­sid­ers the start date and the end date in its cal­cu­la­tions (Fig. 2). 

Number of Fridays
Fig. 2 Num­ber of Fridays

The NETWORKDAYS.INTL func­tion can also work with hol­i­days. Now, only Fri­day hol­i­days are impor­tant for us, so let’s select the cell and press the F4 key to lock it (Fig. 4).

=NETWORKDAYS.INTL(A2,B2,1111011”,$F$3:$F#4)

Holidays on Friday
Fig. 3 Hol­i­days on Friday

And we have our results (Fig. 4). 

Results
Fig. 4 Results

Sum­ming up, 0 means a work­ing day, and 1 means a day off in the sev­en-num­ber text string. If we write 0 also in the fourth place, it means that Thurs­day and Fri­day are work­ing days (Fig. 5). 

=NETWORKDAYS.INTL(A2,B2,1110011”,$F$3:$F#4)

Two working days
Fig. 5 Two work­ing days

As we can see, this small change mod­i­fied our results once again (Fig. 6). 

Modified results
Fig. 6 Mod­i­fied results

https://www.youtube.com/watch?v=6qrKix6QxOs

Highlight weekends and holidays with conditional formatting

Some­times, we want to high­light whole rows of hol­i­days and week­ends. In our case they will be the sec­ond, the third and the fourth of Sep­tem­ber, the sixth of Sep­tem­ber and so on, depend­ing on how many hol­i­days and week­ends we have. We can high­light them with con­di­tion­al for­mat­ting, but first of all, we have to cre­ate a prop­er for­mu­la. We are going to use the NETWORKDAYS func­tion. We want to start with the date from the first row and fin­ish with the same date. We also have to add hol­i­days and lock it (Fig. 1). 

=NETWORKDAYS(A2,A2,$G$2:$G$3)

If a giv­en day is a work­ing day, the func­tion returns 1, and if it’s a day off, it returns 0 (Fig. 2). 

Working days and days off
Fig. 2 Work­ing days and days off

Now, we want to high­light the rows, where we have 0. We can do it by cre­at­ing a prop­er log­i­cal test. We have to check whether a val­ue returned by the NETWORKSDAYS func­tion is equal to 0 (Fig. 3).

=NETWORKDAYS(A2,A2,$G$2:$G$3)=0

Fig. 3 A sim­ple log­i­cal test

Now, we want to ask our­selves how we want our ref­er­ence to behave. Since we want to copy the for­mu­la down, we want to change rows, as there are dif­fer­ent dates in each row. We also want to high­light a whole row, so we always want to look at the first cell in the row because it’s a date. Hav­ing this in mind, we have to lock the col­umn by insert­ing a sin­gle dol­lar sign before the name of the col­umn, but not before the row num­ber. We must do this both in the start date and the end date argu­ment (Fig. 4).

Locked cell
Fig. 4 Locked cell

After copy­ing it down and to the right, we have prop­er results. We have TRUE for week­ends and hol­i­days, and FALSE for work­ing days (Fig. 5). 

Proper results of TRUE and FALSE
Fig. 5 Prop­er results of TRUE and FALSE

Now, we can copy our for­mu­la in the edit mode and select the range in which we want to have con­di­tion­al for­mat­ting. We click on the Shift + , two times to the right, and Ctrl + Shift + ↓ to select the data to the end. While cell A2 is still active, we can go to Home tab, then Con­di­tion­al For­mat­ting, then the New Rule option (Fig. 6). 

New Rule option
Fig. 6 New Rule option

In the New Rule For­mat­ting win­dow, we have to select the Use a For­mu­la to deter­mine which cells to for­mat bar, then paste the for­mu­la into the Edit the Rule Descrip­tion bar, and click on the For­mat tab (Fig. 7). 

New Formatting Rule window
Fig. 7 New For­mat­ting Rule window

In the For­mat Cells win­dow, we select the Fill tab, then choose a nice col­or, then press the OK but­ton in the win­dow, then the OK but­ton in the sec­ond win­dow (Fig. 8).

Format cells window
Fig. 8 For­mat cells window

And there we have it. We can see that each row with a day off is high­light­ed in green (Fig. 9)

Highlighted rows
Fig. 9 High­light­ed rows

Even if we mod­i­fy the hol­i­days, which are our cri­te­ria, our high­light­ed rows also change (Fig. 10). 

Criteria modification
Fig. 10 Cri­te­ria modification

https://www.youtube.com/watch?v=TY8sHfaVgaM

Date after X work days

If you want to find a date after a cer­tain num­ber of work­days, you can use the WORKDAY func­tion. You just need the start date and the num­ber of work­ing days (Fig. 1). 

Date after X work days
 WORKDAY function
Fig. 1 WORKDAY function

We can see that Excel shows the date after the cor­re­spond­ing num­ber of work­ing days. You have to remem­ber that the WORKDAY func­tion does­n’t con­sid­er the start date in its cal­cu­la­tions. It means that if you have only one work­day, you will go to the next work­ing day (Fig. 2). 

Next working day
Fig. 2 Next work­ing day

In the WORKDAY func­tion, you can even add hol­i­days by just select­ing a range with prop­er dates. Remem­ber to lock it (F4) (Fig. 3). 

Adding holidays
Fig. 3 Adding holidays

We can see that our dates are a bit changed (Fig. 4). 

Dates changed
Fig. 4 Dates changed

The WORKDAY func­tion con­sid­ers the week­end as Sat­ur­day and Sun­day, which is cor­rect in most of the coun­tries, how­ev­er we can mod­i­fy it. When we want only Sun­day to be our week­end, we have to choose the WEEKDAYS.INTL func­tion. The func­tion con­sists of the start date and the num­ber of work­ing days. The third argu­ment is the week­end, where we can change the week­end days. Let’s choose Sun­day (Fig. 5). 

Sunday as the weekend
Fig. 5 Sun­day as the weekend

Then, we are choos­ing hol­i­days by select­ing a prop­er range and lock­ing it (F4 key). Our for­mu­la is ready (Fig. 6). 

=WORKDAY.INTL(A2,B2,11,$F$2:$F$3)

Our formula
Fig. 6 Our formula

We can see that our results dif­fer from the the pre­vi­ous ones because now Sat­ur­day is our work­ing day (Fig. 7). 

Saturday as a working day
Fig. 7 Sat­ur­day as a work­ing day

Number Of Working Days Between Two Dates

When we want to count the num­ber of work­ing days between two dates we can use the NETWORKDAYS func­tion. The func­tion is very sim­ple, as it needs only the start and end dates. And that’s it (Fig. 1). 

Num­ber Of Work­ing Days Between Two Dates

=NETWORKDAYS(A2,B2)

NETWORKDAYS function
Fig. 1 NETWORKDAYS function

And we have the num­bers of work­ing days between two dates. It’s impor­tant that the NETWORKDAYS func­tion con­sid­ers also the start and end days. If the start and end days are the same, the num­ber will tell us whether the day is a work­ing day or not (Fig. 2). 

Working days
Fig. 2 Work­ing days

We can also add hol­i­days to this func­tion in the third argu­ment. We just have to select a range with prop­er dates and press the F4 key to lock it (Fig. 3).

=NETWORKDAYS(A2,B2,$F$2:$F$3)

Holidays
Fig. 3 Holidays

Now, we can see that the num­ber of days changed due to those hol­i­days (Fig. 4). 

Changed numbers
Fig. 4 Changed numbers

In the NETWORKDAYS func­tion, the week­end is con­sid­ered as Sat­ur­day and Sun­day. How­ev­er, we can mod­i­fy it by using the NETWORKDAYS.INTL func­tion. The syn­tax of those two func­tions is almost the same. Apart from the start and end day, we can choose what our week­end days will be. Let’s choose Sun­day only (Fig. 5). 

 NETWORKDAYS.INTL function
Fig. 5 NETWORKDAYS.INTL function

Then, we can add hol­i­days if we want. Let’s select the prop­er hol­i­day range and press the F4 key to lock it (Fig. 6). 

=NETWORKDAYS.INTL(A2,B2,11,$F$2:$F$3)

 Function with holidays
Fig. 6 Func­tion with holidays

And we have our results. We can see that the num­ber of work­ing days between the dates grew because Sat­ur­day is a work­ing day (Fig. 7). 

Working days without Sundays
Fig. 7 Work­ing days with­out Sundays

How to group columns and rows

Today, we are going to learn how to group columns and rows. In our exam­ple, we have month by month sales, and their sum­maries by the first quar­ter, the sec­ond quar­ter and half a year with the use of the SUBTOTAL func­tion.

How to group columns and rows
Columns
Fig. 1 Columns

Some­times, we don’t want to show low­er val­ues, i.e. val­ues from indi­vid­ual months. We can do it by hid­ing those columns (Fig. 2).

Hide option
Fig. 2 Hide option

And some­times, we want to show those val­ues (Fig. 3). 

Unhide option
Fig. 3 Unhide option

Those tasks, how­ev­er, can some­times be a bit tedious. That’s why we are going learn how to group those columns to make it sim­pler. First, you have to select the columns you want, then go to the Data tab and click on the Group com­mand. Now, we can see a line above col­umn names, which allows us to hide the columns just by click­ing on the minus sign (Fig. 4). 

Grouped columns
Fig. 4 Grouped columns

We can also unhide them by click­ing on the plus sign (Fig. 5).

Unhiding the grouped columns
Fig. 5 Unhid­ing the grouped columns

Now, the task is quite sim­ple. You can hide or unhide many columns at once. We can group even more columns this way, how­ev­er, it’s impor­tant to have a space of at least one col­umn between those groups so that Excel does­n’t com­bine those groups in one (Fig. 6). 

Groups separated by one column
Fig. 6 Groups sep­a­rat­ed by one column

When we want to ungroup our data, there is a sim­ple solu­tion. You have to go to the Data tab, expand the Ungroup com­mand, and choose the Clear Out­line option (Fig. 7). This way, Excel will clear all groups in the sheet. Usu­al­ly, it’s eas­i­er to clear all groups and start cre­at­ing new groups from the begin­ning than try­ing to fix it. 

Ungrouping data
Fig. 7 Ungroup­ing data

Due to the fact that our val­ues are com­bined from dif­fer­ent columns, we can make Excel group the val­ues for us. You just select any cell, go to the Data tab, expand the Group com­mand and choose the Auto Out­line option (Fig. 8). 

Auto Outline option
Fig. 8 Auto Out­line option

This way, Excel has cre­at­ed three groups for us. Those groups aren’t on the same lev­el because each low­er lev­el group com­bines three columns, and the upper lev­el group com­bines all the columns from the low­er groups and a few more (Fig. 9). 

Groups on different levels
Fig. 9 Groups on dif­fer­ent levels

When we click on the group lev­el num­ber, Excel will expand or col­lapse all groups in this lev­el (Fig. 10). 

Group level numbers
Fig. 10 Group lev­el numbers

Now, let’s group some rows. We don’t have any func­tion that sums up or com­bines rows, so we have to do it man­u­al­ly. We have to select the rows we want, then go to the Data tab, then the Group option (Fig. 11). 

 Row grouping
Fig. 11 Row grouping

If we select a range, not whole columns or rows and press the Group com­mand, Excel does­n’t know which ones we want to group. Then we have to select the prop­er radio but­ton (Fig. 12). 

Selecting the proper option
Fig. 12 Select­ing the prop­er option

We can also select more rows and group them by press­ing the Group option to cre­ate a group on a high­er lev­el. This group will con­sist of groups from a low­er lev­el. We can expand and col­lapse them the using also lev­el num­ber but­tons (Fig. 13). 

Row group levels
Fig. 13 Row group levels

Dynamic chart title, link chart title with a value from the cell

Today, we are going to make a sim­ple trick, i.e. link­ing the Chart Title with a val­ue from a cell. It will make the Chart Title a bit more dynam­ic. The task is sim­ple. We have to select the chart, so that it has sol­id bor­ders. We go to the Chart Title edit mode. As we can see, the Chart Title bor­ders change into a dot­ted line, which we don’t want. We have to click some­thing else on the chart, then click again on the chart title one time, so that the bor­ders stay sol­id (Fig. 1).

Dynam­ic chart title, link chart title with a val­ue from the cell
Solid borders
Fig. 1 Sol­id borders

Now, we have to click the equal sign, which will appear in the for­mu­la bar (Fig. 2).

Equal sign
Fig. 2 Equal sign

We are start­ing to write a for­mu­la for the Chart Title. We are click­ing cell A1 because we want to have ref­er­ence to this cell. Then, we are press­ing Enter to link the Chart Title to this cell (Fig. 3). 

Chart Title linked to a cell
Fig. 3 Chart Title linked to cell A1

When we change a val­ue in the cell, the Chart Title also changes (Fig. 4).

Chart Title changes
Fig. 4 Chart Title changes

This sim­ple trick works also with Axis title. We have to select the Axis title (Fig. 5). 

Selected Axis title
Fig. 5 Select­ed Axis title 

Then, write the equal sign and select a prop­er cell. In our case it’s A10. After enter­ing it, the Axis title changes (Fig. 6). 

Axis title changed
Fig. 6 Axis title changed

We can do the same with the bot­tom Axis title (Fig. 7). 

Bottom Axis title changed
Fig. 7 Bot­tom Axis title changed

That’s how you con­nect the Chart title and Axis titles to val­ues from cells. 

How to extract last row

Today, we want to extract the last row with giv­en cur­ren­cies. Our data is sort­ed ran­dom­ly. If we want to con­sid­er the date col­umn, we will have to sort it first. We can do it man­u­al­ly, by going to the end of date and find the last row. How­ev­er, we want to sort it in Pow­er Query, which is more auto­mat­ic. We just have to select one cell from our table, go to Data tab, and click on the From Table/Range com­mand (Fig. 1). 

How to extract last row
 From Table/Range command
Fig. 1 From Table/Range command

This com­mand exports our data to Pow­er Query. We can see, that Pow­er Query con­sid­ers our data as a date and time. In our exam­ple, it isn’t impor­tant so let’s leave it like that. If we want to sort our dates, we just click on the A to Z sort­ing com­mand on the Home tab (Fig. 2). 

A to Z sorting command
Fig. 2 A to Z sort­ing command

Now, the last row is the newest date (Fig. 3). 

The newest date in the last row
Fig. 3 The newest date in the last row

Since we are inter­est­ed in cur­ren­cies, we want to group our data by the Cur­ren­cy col­umn. We have to click one cell from the Cur­ren­cy columns and go to the Group By com­mand in the Home tab. In the Group By win­dow that has appeared, we can see that the Cur­ren­cy bar is select­ed. In the Oper­a­tion bar, we need to select All Rows and, in the New col­umn name, let’s write tem­po­rary. Then we are press­ing the OK but­ton (Fig. 4).

Group By window
Fig. 4 Group By window

And we have our data grouped by cur­ren­cies (Fig. 5). 

Data grouped by currencies
Fig. 5 Data grouped by currencies

There is a table for each cur­ren­cy that con­tains all rows with a giv­en cur­ren­cy. We have sort­ed the dates ear­li­er, so in the tables, the last date is also the newest exchange rate. And the newest exchange rate is what we want (Fig. 6). 

The newest exchange rate
Fig. 6 The newest exchange rate

Let’s go to the Add Col­umn tab, then to the Cus­tom Col­umn com­mand. A win­dow will appear, where we write the name. Let’s call it Last. Then, we need to write a for­mu­la in the Cus­tom col­umn for­mu­la box. We are writ­ing Table.LastN com­mand to attract the last row of the table. The func­tion we are writ­ing needs a table, so we are choos­ing our table called tem­po­rary, then we need to write the num­ber of rows from the end. We want just one row, so let’s write it, then close the for­mu­la. This is the whole for­mu­la we need, so let’s press the OK but­ton (Fig. 7). 

=Table.LastN(temporary),1)

The formula
Fig. 7 The formula

We can see that we have the Last col­umn. In the col­umn, there are tables, but each table con­tains only one row for each cur­ren­cy (Fig. 8). 

The Last column
Fig. 8 The Last column

We don’t need the tem­po­rary col­umn, so let’s delete it (Fig. 9).

Deleting the temporary column
Fig. 9 Delet­ing the tem­po­rary column

Now, we can expand the Last col­umn by press­ing the icon shown in Fig. 10. In the win­dow that has appeared, we des­e­lect the Cur­ren­cy and the Use orig­i­nal col­umn name as pre­fix check­box­es. Then, we press the OK but­ton (Fig. 10). 

Expanding the Last column
Fig. 10 Expand­ing the Last column

Now, we can see a prop­er table with cur­ren­cy, and the newest date with the exchange rate. Let’s go to the Home tab, and Close&Load to com­mand (Fig. 11). 

Close&Load to command
Fig. 11 Close&Load to command

We moved back to Excel, where we have to select the Exist­ing work­sheet radio but­ton, then click on cell F1 and des­e­lect the Add this data to the Data Mod­el check­box, and press the OK but­ton (Fig. 12). 

Import Data
Fig. 12 Import Data

And we have our results. How­ev­er, we have to remem­ber that Pow­er Query not always extracts prop­er data for­mat­ting. That’s why we have to go to the Home tab and select prop­er data for­mat­ting (Fig. 13). 

Results with proper dates
Fig. 13 Results with prop­er dates

Let’s make a test and change some some dates in dif­fer­ent cur­ren­cies, then refresh our table (Fig. 14). 

Refreshing the table
Fig. 14 Refresh­ing the table

We can see that the Query is auto­mat­ic when we refresh it (Fig. 15). 

Automatic refreshing in Query
Fig. 15 Auto­mat­ic refresh­ing in Query

https://www.youtube.com/watch?v=f0uORcZw73g

First day of the next month

Some­times, we want to get the first day of the next month. I will show you two solu­tions how to cal­cu­late this date in Excel. The first solu­tion uses the DATE func­tion. It needs the num­ber of days, months and years. First, we will write the num­ber of years, which we can extract­ed from the cur­rent date using the YEAR func­tion (Fig. 1).

First day of the next month

=DATE(YEAR(A2

DATE function
Fig. 1 DATE function

The same case is with the month num­ber. We are using the MONTH func­tion and extract­ing the num­ber from the date. How­ev­er, we have to remem­ber that we want to have the next month. That’s why we are adding +1. It’s impor­tant that the DATE func­tion will work with num­bers larg­er than 12. It will just go to the next year, or the pre­vi­ous one if the num­ber is low­er than zero. Then, we are putting 1 because we want the first day of the month. And just like that, we have the whole for­mu­la (Fig. 2).

=DATE(YEAR(A2),MONTH(A2)+1,1)

The whole DATE formula
Fig. 2 The whole DATE formula

After enter­ing and copy­ing it down, we have the results (Fig. 3).

DATE formula results
Fig. 3 DATE for­mu­la results

If we want to go fur­ther into the future, we just have to add more months, let’s say 3 (Fig. 4). 

=DATE(YEAR(A2),MONTH(A2)+3,1)

More into the future
Fig. 4 More into the future

We can see that the func­tion goes to next years in cer­tain dates (Fig. 5).

Next years in some dates
Fig. 5 Next years in some dates

If we want to go back in time, we have to sub­tract a num­ber, let’s write ‑3 (Fig. 6). 

=DATE(YEAR(A2),MONTH(A2)-3,1)

Going back in time
Fig. 6 Going back in time

And we are in the past. As we can see, the num­ber of years is also cal­cu­lat­ed ana­log­i­cal­ly (Fig. 7). 

In the past
Fig. 7 In the past

The sec­ond solu­tion uses the EOMONTH func­tion. We have our start­ing day and the num­ber of months we are mov­ing. Since we want to have the fist day of the next month, first, we need to go to the last day of the cur­rent month (Fig. 8). 

=EOMONTH(A2,0)

EOMONTH function
Fig. 8 EOMONTH function

And we have the last day (Fig. 9).

The last day
Fig. 9 The last day

How­ev­er, we want the day after, so we have to add 1 (Fig. 10). 

=EOMONTH(A2,0)+1

 Adding 1
Fig. 10 Adding 1

Now, we have the first days of the next months (Fig. 11). 

The first day of the next months
Fig. 11 The first day of the next months

When we want to have the first day of the month that is three months into the future, we just have to add 2 months in the sec­ond argu­ment of the EOMONTH func­tion. It’s because we will go 2 months into the future, and then we have +1 at the end, so it sums up to 3 months (Fig. 12).

=EOMONTH(A2,2)+1

3 months into the future
Fig. 12 3 months into the future

And we have prop­er dates (Fig. 13).

Proper dates
Fig. 13 Prop­er dates

Ana­log­i­cal­ly, when we want to go back in time, we need to write one month more than we real­ly want as a neg­a­tive num­ber because we are going to the last day of the month and then we are adding 1, so in total we are going back 3 months (Fig. 14). 

=EOMONTH(A2,-4)+1

3 months into the past
Fig. 14 3 months into the past

And we have the solu­tion (Fig. 15). 

Solution
Fig. 15 Solution

The results are the same, so it’s up to you which solu­tion you will choose. 

https://www.youtube.com/watch?v=T0ijsD81MIs

Last day of a month, EOMONTH function

Some­times, we need to know what the last day of the moth is. In fact, it’s real­ly sim­ple to find it out because we have the end of month func­tion — EOMONTH. This func­tion needs a start­ing day and the num­ber of moths we are mov­ing. When we want the end of the cur­rent month, we just put 0 in the sec­ond argu­ment of the func­tion. Then, we must close the for­mu­la and that’s it (Fig. 1).

Last day of a month, EOMONTH function

=EOMONTH(A2,0)

OEMONTH function with 1
Fig. 1 OEMONTH func­tion with 0

We have the last days of cur­rent months. The EOMONTH func­tion shows the last day even if the start­ing day is the last day of the month (Fig. 2).

EOMONTH with current months
Fig. 2 EOMONTH with cur­rent months

The EOMONTH func­tion can move to the future. When we want to go one month into the future, we just put pos­i­tive num­ber (for exam­ple 1) instead of 0 (Fig.3).

=OEMONTH(A2,1)

OEMONTH with 1
Fig. 3 OEMONTH with 1

And we have the last days of the next month (Fig. 4).

Last days of next months
Fig. 4 Last days of next months

If we put a big­ger num­ber (Fig.5),

=EOMONTH(A2,3)

EOMONTH with a bigger number
Fig. 5 EOMONTH with a big­ger number

we will move more into the future (Fig. 6). 

More distant months
Fig. 6 More dis­tant months

Ana­log­i­cal­ly, if we want to move back in time, we just write a neg­a­tive num­ber. Let’s write ‑1 (Fig. 7). 

=EOMONTH(A2, ‑1)

EOMONTH with a negative number
Fig. 7 EOMONTH with a neg­a­tive number

And we are in the pre­vi­ous month (Fig. 8).

Previous months
Fig. 8 Pre­vi­ous months

If we want to move even more into the past, we just write big­ger neg­a­tive num­bers (Fig. 9).

=EOMONTH(A2,-3)

EOMONTH with a bigger negative number
Fig. 9 EOMONTH with a big­ger neg­a­tive number

As a result, the EOMONTH func­tion can move us even to pre­vi­ous or next years (Fig. 11). 

Previous or next years
Fig. 11 Pre­vi­ous or next years