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

SUMIFS AVERAGEIFS and COUNTIFS functions SUM with conditions

Today, we are count­ing sums, aver­ages and num­ber of trans­ac­tions with more than one con­di­tion. In our exam­ple, we have trans­ac­tion sales table and we want to count the val­ues for giv­en months. How­ev­er, the months are writ­ten as the first day of the month and the last day of the month. It means that we have to add two con­di­tions in order to count it. Let’s start with sums. We can use the SUMIFS func­tion. The first argu­ment of this func­tion is a range on which we will be sum­ming. In our case it’s the sales col­umn so we have to select cell C2 and press the Ctrl + Shift + ↓ com­bi­na­tion, then the F4 key to lock it (Fig. 1).

=SUMIFS($C$2:$C$1193

SUMIFS AVERAGEIFS and COUNTIFS func­tions SUM with conditions
SUMIFS function with a locked range
Fig. 1 SUMIFS func­tion with a locked range

We write a com­ma, and then we are going to the cri­te­ria range 1. This will be the range where we will be check­ing the first cri­te­ri­on, which is the third argu­ment of the SUMIFS func­tion. In our case, we are check­ing dates, so let’s press cell A2, Ctrl + Shift + ↓, then the F4 key. We are adding a com­ma again, and now we have to write the first con­di­tion, which is the first cri­te­ri­on. The order of our con­di­tions is not impor­tant because, in the end, all con­di­tions have to be met to count the thing we want. Let’s start with the From date. We want val­ues that are big­ger or equal to this date, which means that we have to write the sym­bols of larg­er than and equal in dou­ble quotes, then an amper­sand because we are com­bin­ing this text with the val­ue from cell E2 (Fig. 2).

=SUMIFS($C$2:$C$1193,$A$2:$A$1193,”>=”&E2

SUMIFS with the first condition
Fig. 2 SUMIFS with the first condition

After press­ing the F9 key, we can see that Excel changed the date into a num­ber. This makes Excel check our con­di­tion prop­er­ly (Fig. 3).

=SUMIFS($C$2:$C$1193,$A$2:$A$1193,“>=43831”

Excel changed the dated
Fig. 3 Excel changed the dates

How­ev­er, let’s move back to pre­vi­ous text by press­ing Ctrl + Z. Now, we have the first con­di­tion. We can see that the sec­ond con­di­tion is nec­es­sary with sec­ond critiri­on because the next two argu­ments are in square brack­ets (Fig. 4).

=SUMIFS($C$2:$C$1193,$A$2:$A$1193,”>=”&E2

Arguments in square brackets
Fig. 4 Argu­ments in square brackets

Cri­te­ria range 2 in our case is the same as cri­te­ria range 1, so we can just copy it (Ctrl +C, Ctrl +V), but we real­ly need to put it because each cri­te­ria range is work­ing just with the argu­ment of its cri­te­ria. It means that cri­te­ria range 1 is work­ing with cri­te­ria 1, and cri­te­ria range 2 is work­ing with cri­te­ria 2. In our case, the cri­te­ria 2 are num­bers small­er than or equal to the last day of the month in cell F2. 

Now, we have the whole for­mu­la (Fig. 5). 

=SUMIFS($C$2:$C$1193,$A$2:$A$1193,”>=”&E2,$A$2:$A$1193,”<=”&F2)

Whole SUMIFS formula
Fig. 5 Whole SUMIFS formula

When we want to sum the val­ues from the sum range, the first and the sec­ond con­di­tion have to be met. Let’s put the for­mu­la and copy it down. We can see that at the end every­thing is work­ing prop­er­ly because we have writ­ten the for­mu­la prop­er­ly (Fig. 6).

Proper results
Fig. 6 Prop­er results

We still have some more val­ues to count. Let’s take the aver­ages. Since I’m a lazy per­son, I will copy the whole for­mu­la in edit mode, then go to the Aver­age col­umn, paste it and change only the name of SUMIFS into AVERAGEIFS. After enter­ing it, we can see that only the sum range changed its name into aver­age range. The remain­ing argu­ment names stayed the same. It’s because the SUMIFS and the AVERAGEIFS for­mu­las have the same syn­tax, but they count sums and aver­ages cor­re­spond­ing­ly (Fig. 7). 

Argument name change
Fig. 7 Func­tion name change

Let’s put the for­mu­la into our cell and copy it down. We have the results (Fig 8).

SUMIFS reults
Fig. 8 SUMIFS reults

Let’s now count the num­ber of trans­ac­tions. We will use the COUNTIFS func­tion. This func­tion does­n’t have any range on which we could count sums, aver­ages and so on. It only needs cri­te­ria ranges and cri­te­ria. Our first cri­te­ria was the one with dates. So, let’s write A2, then press Ctrl + Shift + ↓, then the F4 key to lock it and a com­ma. I want to show you that the order of con­di­tions is not impor­tant. Let’s take val­ues small­er that or equal to the date in cell F2, com­ma, then the same cri­te­ria range, then the sec­ond cri­te­ria will be greater than or equal to the val­ue from cell E2. Those are all the argu­ments we need for a COUNTIFS func­tion (Fig. 9).

=COUNTIFS($A$2:$A$1193,”<=”&F2,$A$2:$A$1193,”>=”&E2)

COUNTIFS formula
Fig. 9 COUNTIFS formula

After copy­ing the for­mu­la down, we have the results. We can check if our aver­age is cor­rect just by look­ing at it because it is just the sum divid­ed by the num­ber of trans­ac­tions (Fig. 10).

Checking the results
Fig. 10 Check­ing the results

We can see that the num­bers are exact­ly the same as in the Aver­age col­umn (Fig. 11). 

The same numbers
Fig. 11 AVERAGEIFS and divide gives the same results

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

Combine text with different delimiters

Today, we are going to com­bine text with two, dif­fer­ent delim­iters. In our exam­ple, we have shop and street names. We want to put a semi­colon between each shop and street name. How­ev­er, between street and shop names we want to put anoth­er sym­bol, which is a pipe. What is impor­tant in our exam­ple, is the fact that not all cells are filled. We want to just ignore them while com­bin­ing text (Fig. 1).

Com­bine text with dif­fer­ent delimiters
Fig. 1 — Text to combine

This task is very sim­ple in Excel 2019 and new­er ver­sions because we have the TEXTJOIN func­tion. In the first argu­ment of this func­tion, we are putting the delim­iter. We can even put more than one delim­iter. In our exam­ple, the delim­iters are placed in cells D9 and E9, so let’s put them in the for­mu­la and let’s lock them by press­ing the F4 key. When we put more than one delim­iter in the TEXTJOIN func­tion, the func­tion will use them alter­na­tive­ly, which means that first, it will use the semi­colon, then the pipe, then the semi­colon and so on. In next argu­ment we have to decide whether we want to ignore emp­ty cells or not. In this case, as I said ear­li­er, it’s very impor­tant for us to ignore them, so we are writ­ing TRUE or 1. The last argu­ment we need is just text, i.e. the range with text. Let’s close the for­mu­la (Fig. 2)

=TEXTJOIN($D$9:$E$9,1,B2:G2)

Fig. 2 — For­mu­la for com­bin­ing text

After putting it into the cell, let’s copy it down. We have the results. We can see there are semi­colons between shop and street names, and pipes between street and shop names (Fig. 3).

Fig. 3 — Com­bined text

In the TEXTJOIN for­mu­la, delim­iters ori­en­ta­tion is not impor­tant. They can be hor­i­zon­tal or vertical.

We can even hard­code them here by select­ing first argu­ment and press­ing the F9 key to eval­u­ate it. Now, they are writ­ten as text (Fig. 4).

=TEXTJOIN({“;”,”|”},1,B2:G2)

Fig. 4 — Hard­code delimiters

We can leave them like that and the for­mu­la will work the same. 

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

Combine Text from Two or more Cells

Today, we are going to com­bine or con­cate­nate two or more texts togeth­er. Let’s start with cre­at­ing full names. It is a sim­ple exam­ple with two texts. We can use the CONCATENATE func­tion, or, if you have Excel 2019 or a new­er one, you can just use the CONCAT func­tion which com­bines two text ranges. The CONCATENATE func­tion can­not com­bine ranges, only sin­gle cells. How­ev­er, in our exam­ple, it does­n’t mat­ter because when we com­bine the first name and the last name, in real­i­ty, we want to com­bine three texts as there is a delim­iter between the first and last name. That’s why we have to add, let’s say, a space. The space should be in dou­ble quotes because it is a text (Fig. 1).

Com­bine Text from Two or more Cells

=CONCATENATE(A2,” “,B2)

CONCATENATE function
Fig. 1 CONCATENATE function

After enter­ing and copy­ing it down, we have full names (Fig. 2). 

 Full names
Fig. 2 Full names

If you don’t like using the func­tion, you can use the amper­sand sign (&) to com­bine texts. How­ev­er, while using the sign, it is impor­tant to put the sign between each point of con­nec­tion. It means that the & sign must be placed between the first cell address and the space, and between the space and anoth­er cell address (Fig. 3) 

=A2&” “&B2

Ampersand signs in a formula
Fig. 3 Amper­sand signs in a formula

After enter­ing the for­mu­la, we have the same results as after using a func­tion (Fig. 4). It is up to you which one you choose. 

The same results
Fig. 4 The same results

In our sec­ond exam­ple, we want to com­bine more than one text togeth­er, i.e., the first, mid­dle and last name. We will use the CONCATENATE func­tion once more, but this time we are click­ing on the insert func­tion com­mand near the for­mu­la bar and we can see that a Func­tion Argu­ment win­dow appeared. In the win­dow, we have argument/text box­es where we will write our text. We can choose a text from a cell (press Tab). In the Text2 bar, we can write a space. When we press the Tab key, Excel will add dou­ble quotes for us. In the Text3 bar there will be cell B2. In the next bar below, we do the same with writ­ing a space. In the last bar, we place cell C2. We can even see our for­mu­la result straight in the Func­tion Win­dow (Fig. 5).

=CONCATENATE(A2,” “,B2,” “,C2)

Function Arguments window
Fig. 5 Func­tion Argu­ments window

After enter­ing the for­mu­la, we have our results (Fig. 6). In this exam­ple, using the Insert Func­tion com­mand was quite fast. 

Formula results
Fig. 6 For­mu­la results

I have also pre­pared one more func­tion that exists from Excel 2019. It is called TEXTJOIN. It can com­bine text from ranges with the same delim­iter. In our case, the delim­iter is a space, so we have to write a space in dou­ble quotes. Then, we have to decide if we want to ignore emp­ty cells. In most cas­es yes, so we can write either TRUE or 1. Let’s write 1 because it is short­er. Then, we are select­ing the text range, which is the cells that we want to join (Fig. 7)

=TEXTJOIN(“ “,1,A2:C2)

TEXTJOIN function
Fig. 7 TEXTJOIN function

After enter­ing the for­mu­la and copy­ing it down, we have our results (Fig. 8)

TEXTJOIN function results
Fig. 8 TEXTJOIN func­tion results

While com­bin­ing many texts, it is very impor­tant to choose prop­er func­tion. Let’s assume that some peo­ple don’t have mid­dle names. In such a case, the TEXTJOIN func­tion will ignore emp­ty cells and will add only one space. How­ev­er, the CONCATENATE func­tion will leave two spaces. In such a sit­u­a­tion we would have to use the IF func­tion to prop­er­ly address this prob­lem (Fig. 9).

One space and two spaces in different functions
Fig. 9 One space and two spaces in dif­fer­ent functions

Sum­ming up, we joined the first, mid­dle and last name in each row using the CONCATENATE func­tion that com­bines more than two texts, and the TEXTJOIN func­tion that com­bines a range of texts. 

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

COLUMNS function — how many columns in a range

When you want to count the num­ber of columns in a range, you can use the COLUMNS func­tion and select a prop­er range (Fig. 1)

COLUMNS func­tion — how many columns in a range

=COLUMNS(B13:E17)

Fig. 1 COLUMNS function

The func­tion will return the num­ber of columns in this range (Fig. 2)

Number of columns
Fig. 2 Num­ber of columns

You can also cre­ate a hor­i­zon­tal sequence of num­bers. You just have to write the COLUMNS func­tion and cre­ate a prop­er range, let’s say B13 to B13. In this case, it is impor­tant to lock one of the cells with a $ sign by press­ing the F4 key so that it does­n’t move (Fig. 3)

=COLUMNS($B$13:B13)

COLUMNS function with a range
Fig. 3 COLUMNS func­tion with a range

After enter­ing the for­mu­la and copy­ing to the right, we can see that our range expands, i.e. one cell stays the same, and the oth­er one is mov­ing to the right (Fig. 4).

Formula changes
Fig. 4 For­mu­la changes

https://www.youtube.com/shorts/mQRaB86awNQ