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

SUM and AVERAGE with condition — SUMIF and AVERAGEIF functions

Today, we are going to count sums and aver­ages with con­di­tions. In our first exam­ple, we have a small table where we sell fruit. We want to sum up the whole weight and aver­age weight for a sin­gle cell. To sum the val­ues with con­di­tions we can use the SUMIF func­tion. In the first argu­ment, we write the range where we need to check our con­di­tion and lock it by press­ing the F4 key. In the sec­ond argu­ment, which is cri­te­ria, we just put a ref­er­ence to a sin­gle cell with the prod­uct name. We don’t have to lock the cell because while copy­ing the for­mu­la down, we want the fruit names to change. The third argu­ment of the func­tion is the sum range. It is closed in square brack­ets which means that it is not nec­es­sary write it, how­ev­er we will do it. We want to sum val­ues from the Weight col­umn. Then the F4 key to lock it (Fig. 1).

SUM and AVERAGE with con­di­tion — SUMIF and AVERAGEIF functions

=SUMIF($B$2:$B$10,F2,$C$2:$C$10)

 SUMIF function
Fig. 1 SUMIF function

After all argu­ments have been writ­ten, let’s look at our ranges and try to under­stand how the SUMIF func­tion works. The func­tion will look at each cell in the Prod­uct col­umn and check if they meet the con­di­tions. In the first cell, we have apples, which means that the con­di­tion is met. In such a sit­u­a­tion, the func­tion will keep on look­ing for the third argu­ment placed in the same row. If it finds it, it will add the val­ue. If there is anoth­er cell that meets the same con­di­tion, it will also add the val­ue from the same row (Fig. 2).

Finding conditions
Fig. 2 Find­ing conditions

Our for­mu­la looks as fol­lows (Fig. 3).

=SUMIF($B$2:$B$10,F2,$C$2:$C$10)

SUMIF formula
Fig. 3 SUMIF formula

After enter­ing and copy­ing down, we can see how many apples, pears and oranges we have sold (Fig. 4).

Results
Fig. 4 Results

Now, let’s try to count the aver­age weight of a sin­gle sale. We just have to copy our SUMIF for­mu­la in the edit mode and paste it into the cell in the Aver­age col­umn. The SUMIF and the AVERAGE func­tions have the same argu­ments. We just change the func­tion name. We can see that the name of the third argu­ment changed from sum range into aver­age range, how­ev­er it is still the same Weight col­umn (fig. 5).

=AVERAGEIF($B$2:$B$10, F2,$C$2:$C$10)

Name change
Fig. 5 Name change

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

Fig. 6 AVERAGEIF counted

Let’s move on to our sec­ond exam­ple. We want to check here what would hap­pen if we give the AVERAGEIF or SUMIF func­tion just two argu­ments. In this exam­ple, we just want to count the aver­age sale. We are start­ing with a sim­ple AVERAGE func­tion with­out con­di­tions, so with­out IFs, for the Sales col­umn (Fig.7).

=AVERAGE(C2:C11)

Simple AVERAGE function
Fig. 7 Sim­ple AVERAGE function

After enter­ing it, we have the aver­age (Fig. 8). 

Average
Fig. 8 Average

Now, let’s count the aver­age with a con­di­tion. We don’t want to count the val­ue if it equals 0. Let’s write the AVERAGEIF func­tion, select the same range and write the con­di­tion. We open dou­ble quotes and write <>0 and close it. When we don’t write the third argu­ment in the AVERAGEIF or SUMIF func­tions, Excel takes the first range as the range in which we are doing our cal­cu­la­tions. In this sit­u­a­tion Excel does­n’t take emp­ty cells and cells with 0 into cal­cu­lat­ing the aver­age. After enter­ing it, we can see dif­fer­ent results. It’s because our con­di­tion was trig­gered in the AVERAGEIF func­tion, which means that Excel did not count the cells with 0 (Fig. 9). 

Different results
Fig. 9 Dif­fer­ent results

When we delete the val­ue with 0, we can see that the AVERAGE and AVERAGEIF func­tion return the same results. It’s because func­tions such as AVERAGE, SUMS, MIN and MAX do not con­sid­er emp­ty cells (Fig. 10).

Results without empty cells
Fig. 10 Results with­out emp­ty cells

How­ev­er, when we put 0 into the cells, the AVERAGE func­tion will count it which means that the aver­age will go down (Fig. 11).

Fig. 11 Results with zeros

Sum­ming up, a sim­ple AVERAGE func­tion counts cells with 0, and the AVERAGEIF func­tion does­n’t due to the condition. 

In Excel, in most sit­u­a­tions, emp­ty cells are treat­ed as 0. 

https://www.youtube.com/watch?v=5h7hVwUjoWA

COUNTIF function — how many times we sell apples

Today, we want to count how many times we sold apples, pears and oranges. We are going to use a small table to check our results, because with a big­ger table it isn’t going to be easy. We will use the COUNTIF func­tion. This func­tion has got only two argu­ments. The first one is a range, where we will be check­ing our con­di­tions or cri­te­ria. In our case, the cri­te­ri­on is the name of our prod­uct, so we are select­ing the cell with the prod­uct name. Such a func­tion will check each cell in the range, whether it con­tains the name or not.

COUNTIF func­tion — how many times we sell apples

=COUNTIF(B2:B10,F2)

COUNIF function
Fig. 1 COUNTIF function

If a cell con­tains the name, the func­tion will add 1 to the counter. We can see that there are four 1s. 

 Four 1s
Fig. 2 Four 1s

We also have to lock the range by press­ing the F4 key, so that it stays in the same place. Cri­te­ria, how­ev­er, should not be locked because we want them to change while copy­ing the for­mu­la down, i.e. we want a giv­en prod­uct to change.

=COUNTIF($B$2:$B$10,F2)

Locked range
Fig. 3 Locked range

After enter­ing and copy­ing down, we have our results. We can see that apples have been sold four times, pears three times and oranges two times. It will also work with big­ger tables. All we need to do is to write a big­ger range.

=COUNTIF($B$2:$B$10,F2)

Final results
Fig. 4 Final results

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

Random list no repeats, manual and formulas solutions

Today, we are going to talk about choos­ing a ran­dom ele­ment from a list with­out repeats. We have eight ele­ments in our list. I put there the same num­ber two times, which gives me the oppor­tu­ni­ty to choose the same num­ber two times. If there are three the same num­bers, I could choose the num­ber up to three times. How­ev­er, the choos­ing is ran­dom, so I don’t real­ly know how many times I will choose it. 

Ran­dom list no repeats, man­u­al and for­mu­las solutions
 A list of elements
Fig. 1 A list of elements

If we want to choose an ele­ment from the list at ran­dom with­out repeats, we can use a man­u­al solu­tion. We need to write the RAND func­tion which returns num­bers from 0 to 1 with fif­teen dig­it pre­ci­sion. It means that it’s almost impos­si­ble to choose the same num­ber twice (Fig. 2). 

=RAND()

RAND function
Fig. 2 RAND function

After drag­ging for­mu­la down, we have 8 ran­dom num­bers. We have to remem­ber that the RAND func­tion is a volatile func­tion. It means that it is recal­cu­lat­ed every time our work­sheet changes (Fig. 3).

Recalculation
Fig. 3 Recalculation

Now, that we have our helper col­umn, we can do the sort­ing. We go to Data tab and we choose the A to Z or Z to A command.

Sorting
Fig. 4 Sorting

If we want to have, e.g. five ele­ments, we have to choose five ele­ments from the top. It does­n’t mat­ter whether we sort from A to Z or Z to A. We just choose the first five ele­ments. We can see that the num­bers are recal­cu­lat­ed every time we sort our data (Fig. 5)

Five elements from the list
Fig. 5 Five ele­ments from the list

Let’s get back to our orig­i­nal list and try the sec­ond solu­tion. It is from Lega­cy Excel and it uses for­mu­las. Let’s start with a way to sort our num­bers. We can use, e.g. the LARGE func­tion, which returns the biggest num­ber from the list, then the sec­ond biggest, then the third biggest, and so on. We have to press the F4 key to lock our list. Then, we need a way to choose the first, the sec­ond, and so on num­bers. So, we want to change our key argu­ment using a prop­er func­tion. One of the sim­plest solu­tion I know is using the ROW func­tion with ref­er­ence to cell A1, which is free (with­out $ signs). When we copy our for­mu­la down, our A1 ref­er­ence will also go down, and the ROW func­tion will return the first row, the sec­ond, the third, and so on (fig. 6)

=LARGE($B$2:$B$9,ROW(A1))

ROW function
Fig. 6 ROW function

After enter­ing the for­mu­la, we have our num­bers placed from the largest to the small­est. Our five ele­ments are now in a prop­er order. It means that now we can choose ele­ments. How­ev­er, we must use the MATCH and INDEX func­tion in our data ori­en­ta­tion. Let’s add the MATCH func­tion to find the posi­tion of our num­ber. We have to add the range, which is our ran­dom num­ber col­umn and press the F4 key to lock it. Then, we are adding 0 because we want to have the exact match (Fig. 7)

=MATCH(LARGE($B$2:$B$9,ROW(A1)),$B$2:$B$9,0)

MATCH function
Fig. 7 MATCH function

After enter­ing and copy­ing down, we have posi­tions of the largest num­bers. When we look at the first posi­tion in our Cho­sen col­umn, we have 5. It means that the largest num­ber from our orig­i­nal list is locat­ed in the 5th place. 

Position of the largest number
Fig. 8 Posi­tion of the largest number

How­ev­er, we don’t want to have posi­tion num­bers, but the ele­ments con­nect­ed to those num­bers. It means that we have to add the INDEX func­tion to our MATCH func­tion. This time, we want to choose ele­ments from our list, so we are adding the range and lock it by press­ing the F4 key. It turns out that our MATCH func­tion is the row num­ber. We have to close the for­mu­la (Fig. 9)

=INDEX($A$2:$A$9,MATCH(LARGE($B$2:$B$9,ROW(A1)),$B$2:$B$9,0))

INDEX function
Fig. 9 INDEX function

After enter­ing and copy­ing down, we have ele­ments select­ed at ran­dom with­out repeats. When I press the F9 key, I am forc­ing it to recal­cu­late our results. Some­times, we see our num­ber (123) twice because it is twice on our orig­i­nal list (Fig. 10)

Elements selected at random
Fig. 10 Ele­ments select­ed at random

It’s high time we tried the final solu­tion in Dynam­ic Array Excel. This solu­tion is sim­pler that the one in Lega­cy Excel because we just need two func­tions. In DA Excel, we have the RANDARRAY func­tion which can cre­ate a ran­dom array. We just need to copy the same col­umn into our for­mu­la, which means that we need an array with eight rows and one col­umn. That’s why we are writ­ing just 8 (Fig. 11).

=RANDARRAY(8)

RANDARRAY function
Fig. 11 RANDARRAY function

After putting our for­mu­la into Excel, we have eight ran­dom num­bers. In DA Excel, we can sort by this col­umn. Thus, we have to add the SORTBY func­tion to our for­mu­la. The array which we want to sort is our list. This time, we don’t have to lock it because it is a DA for­mu­la, and our for­mu­la is the result (Fig. 12). 

=SORTBY(A2:A9,RANDARRAY(8))

SORTBY function
Fig. 12 SORTBY function

After putting the for­mu­la down, we have eight ele­ments from our list in a ran­dom order. Press­ing the F9 key allows us to choose ele­ments once again at ran­dom. Let’s choose five ele­ments from the top once again. We still can see the remain­ing ele­ments. If you don’t want to see them, you have some options. You can, for exam­ple, select five ele­ments from our list, then press the F2 key to go to the for­mu­la edit mode, then press the Ctrl + Shift + Enter com­bi­na­tion to cre­ate an array for­mu­la. The array for­mu­la is from Lega­cy Excel. Now, we have only five ele­ments because I’ve select­ed only five cells. Those cells are an array, which means that we can­not change or delete any sin­gle ele­ment of the array. If you want to change it, you have to change the whole array at one time (Fig. 13).

An array
Fig. 13 An array

Sum­ming up, if you want to choose an ele­ment at ran­dom from a list, you can use a man­u­al solu­tion, a Lega­cy Excel solu­tion or a Dynam­ic Array solution. 

https://www.youtube.com/watch?v=myT-vQzDSeE

ROWS function, how many rows in a range

When you want to count the num­bers of rows in a range, you can use the ROWS func­tion. This func­tion looks only at rows in a giv­en range, and in the end, it returns the num­bers of rows from the select­ed range. 

ROWS func­tion, how many rows in a range

=ROWS(B11:C16)

ROWS function for a given range
Fig. 1 ROWS func­tion for a giv­en range

The ROWS func­tion allows you also to cre­ate a sequence of num­bers. We just have to select a prop­er range (from cell C11 to C11) (Fig. 2), but we have to lock the first C11 cell with a $ sign.

=ROWS($C$11:C11)

Locking the cell
Fig. 2 Lock­ing the cell

Then, we copy the for­mu­la down. We can see that our range keeps expand­ing because the first cell stayed the same, and the sec­ond cell keeps mov­ing down (Fig. 3)

Expanding range
Fig. 3 Expand­ing range

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

Mixed cell references, multiplication table and dividing profits

Today, we are going to talk about mixed cell ref­er­ences and we will start with the sim­plest exam­ple, which is the mul­ti­pli­ca­tion table. Mul­ti­pli­ca­tion is sim­ple. We just have to mul­ti­ply the row head­er by the col­umn head­er. We are going to write a for­mu­la in cell B3, then we are going to copy the for­mu­la down and to the right. First, we are refer­ring to cell A3. Then we have to ask our­selves how our ref­er­ence should change while copy­ing it down and to the right. Let’s look at our data which we will be refer­ring to. We’re start­ing with row head­ers. Our row head­ers are in one col­umn and many rows (Fig. 1).

Mixed cell ref­er­ences, mul­ti­pli­ca­tion table and divid­ing profits
Row headers
Fig. 1 Row headers

It means that the rows are chang­ing but the columns stay the same. Thus, we have to lock the col­umn name, not the row num­ber. We can use the F4 key which cycles through cell ref­er­ence types. It turns out that we had to press the F4 key three times, so that the $ sign is before the col­umn name, not before the row num­ber (Fig. 2).

=$A3

Locked column name
Fig. 2 Locked col­umn name

It means that the col­umn name should stay the same, but the row num­ber should change. We want to mul­ti­ply them so we are adding cell B2. Let’s look at the head­ers once again. As we can see, our col­umn head­ers are placed in one row, but many columns. 

=$A3*B2

Column headers on one row
Fig. 3 Col­umn head­ers on one row

This time, we want to lock the rows, not the columns. We have to click the F4 key two times, so that the $ sign is before the row num­ber, not the col­umn name, which means that the rows should stay the same, but the columns should change (Fig. 4).

=$A3*B$2

Locked row number
Fig. 4 Locked row number

After enter­ing the for­mu­la, copy it down and to the right. We can see that the results are prop­er (Fig. 5)

Proper results
Fig. 5 Prop­er results

Let’s check the last cell. We can see that we have prop­er cell ref­er­ence to row head­ers, as we still refer to col­umn A, and the rows changed. Ana­log­i­cal­ly, for col­umn head­ers, we can see that the columns changed, and the row stayed the same (Fig. 6).

Proper cell reference
Fig. 6 Prop­er cell reference

That’s how mixed cell ref­er­ence works. It will work in many dif­fer­ent exam­ples, like the one below. We have to divide prof­its for share­hold­ers. The sit­u­a­tion is ana­log­i­cal. Our prof­its are in one col­umn and many rows (Fig. 7)

Profits in one column
Fig. 7 Prof­its in one column

We have to lock the col­umn name, i.e. the $ sign should be placed before the col­umn name, not before the row num­ber. Then, we want to mul­ti­ply it by per­cent­ages. They are in one row — row num­ber 3, which should­n’t change (Fig. 8).

=$B6*

Percentage in one row
Fig. 8 Per­cent­age in one row

So, when we refer to cell C3, we have to lock the rows, not the columns because they are chang­ing. Let’s press the F4 key twice and lock the rows (Fig. 9).

=$B6*C$3

Cell C3 reference
Fig. 9 Cell C3 reference

After copy­ing the for­mu­la down and to the right, we have prop­er results. 

Proper results
Fig. 10 Prop­er results

That’s how you use mixed cell references. 

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

Format Painter — How to copy cell formatting

Today, we are going to talk about copy­ing cell for­mat­ting from one cell to anoth­er. We just have to click a giv­en cell, then go to Home tab, press the For­mat Painter com­mand and click on the cell to which you want to copy the for­mat­ting (Fig. 1).

For­mat Painter — How to copy cell formatting
Copying from one cell to another
Fig. 1 Copy­ing from one cell to another

The For­mat Painter can also copy the for­mat­ting from more than one cell. We just select the cells, then click on the For­mat Painter, then select the range to which you want to copy the for­mat­ting, and enter it (Fig. 2).

Copying to more that one cell.
Fig. 2 Copy­ing to more that one cell. 

When you select a cell range and you dou­ble-click the For­mat Painter com­mand, the copy­ing process is going until you press the Esc key. You can even go to oth­er sheets, and copy the for­mat­ting there. 

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