COUNTA Function counting almost everything

Today, we are going to talk about the COUNTA func­tion. This func­tion counts almost every­thing, It counts for­mu­la results (Fig. 1),

COUNTA Func­tion count­ing almost everything
Formula results
Fig. 1 For­mu­la results

num­bers writ­ten as text (Fig. 2), 

Numbers written as text
Fig. 2 Num­bers writ­ten as text

dates and time (Fig. 3),

Dates and time
Fig. 3 Dates and time

log­i­cal val­ues (Fig. 4),

Logical values
Fig. 4 Log­i­cal values

num­bers (Fig. 5),

Numbers
Fig. 5 Numbers

and errors (Fig. 6). 

Errors
Fig. 6 Errors

It even counts a sin­gle num­ber or val­ue that we put as an argu­ment to COUNTA func­tion (Fig. 7) 

A number put as an argument
Fig. 7 A num­ber put as an argument

Let’s write an array with four ele­ments. It does­n’t mat­ter how many columns of rows this array has, but it’s impor­tant how many ele­ments there are. So, we have a range of two cells with num­bers, a sin­gle val­ue and four ele­ments (Fig. 8). 

A range, a single value and four elements
Fig. 8 A range, a sin­gle val­ue and four elements

Since COUNTA func­tion counts every ele­ment, it returns 7 (Fig. 9)

The function returned 7
Fig. 9 The func­tion returned 7

How­ev­er, there is one thing that the COUNTA func­tion does­n’t count. It does­n’t cells that are real­ly emp­ty. Cell A14 is real­ly emp­ty, how­ev­er cell B14 isn’t. It has got a for­mu­la that returns an emp­ty text string. COUNTA func­tion counts an emp­ty text string (Fig. 10).

Empty text string
Fig. 10 Emp­ty text string

Even if a for­mu­la returns a val­ue from an emp­ty cell (B15), the COUNTA func­tion will count cell A15 because it has got a for­mu­la (Fig. 11)

 A cell with a formula
Fig. 11 A cell with a formula

The for­mu­la in cell B14 was count­ed by the COUNTA func­tion (Fig. 12)

A cell with a formula
Fig. 12 A cell with a formula

How­ev­er, if we delete the for­mu­la, the COUNTA func­tion will return 0 because cells A14 and B14 are now real­ly emp­ty (Fig. 13)

Empty cells
Fig. 13 Emp­ty cells

Sum­ming up, the COUNTA func­tions counts every­thing except for emp­ty cells. 

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

Paste as values, the Paste Special window

Some­times, when we have for­mu­la results, we want to have only the text, i.e. the answer (Fig. 1). 

Paste as val­ues, the Paste Spe­cial window
TRIM function results
Fig. 1 — TRIM func­tion results

We can copy the results, then right click a tar­get cell and choose the Paste Val­ues option from the pop-up menu (Fig. 2). 

Fig. 2 — Pop-up menu — Paste values

And, we have just text not for­mu­la (Fig. 3).

Pasted values (text)
Fig. 3 — Past­ed val­ues (text)

There is one more solu­tion. When we copy our for­mu­la, we click on a tar­get cell and press Alt + Ctrl + V com­bi­na­tion to show the Paste Spe­cial win­dow (Fig. 4). In the Paste area, we click Val­ues, in the Oper­a­tion area, we choose None, then we press OK. 

Paste Special window
Fig. 4 — Paste Spe­cial window

Now, we have the results only once. We don’t need the extra col­umn, so we must delete it (Fig. 5) 

Deleting column
Fig. 5 — Delet­ing column

https://www.youtube.com/shorts/3UD7n8Jtu3I

Relative and absolute cell references

Today, we will dis­cuss rel­a­tive and absolute ref­er­ences. Let’s start with rel­a­tive ref­er­ences to count a prof­it. If you want to count the prof­it, you just deduct expens­es from income (Fig. 1).

Rel­a­tive and absolute cell references

Source data
Fig. 1 — Source data

It means that you sub­tract the cell C3 val­ue from the val­ue in cell B3 (Fig. 2):
=B3 — C3

 Income minus expenses
Fig. 2 — Income minus expenses

When we copy this for­mu­la down, it’s chang­ing because we have dif­fer­ent results in dif­fer­ent cells. When we look at our for­mu­la, it refers to cells B3 and C3. But, in real­i­ty, it refers the cells which are one place to the left and two places to the left (Fig. 1). In the last for­mu­la (=B14-C14), we can see B14 minus C14 (Fig. 3) but it’s still one cell to the left and two cells to the left. The rel­a­tive ref­er­ence is mov­ing with the for­mu­la and cell.

Formula change after copying down
Fig. 3 — For­mu­la change after copy­ing down

We don’t always want the for­mu­la to behave this way. In our sec­ond exam­ple you can see an absolute ref­er­ence. We want to count the tax for each prod­uct. That’s why we have to mul­ti­ply the price by our tax. How­ev­er, we don’t want the tax cell to move, so we must lock cell J2 by press­ing F4 key — add two $ signs (Fig. 4):

=G2*$J$2

Tax calculations
Fig. 4 Tax calculations

When we copied our for­mu­la down, only cell G2 had changed because it’s a rel­a­tive ref­er­ences. Cell J2 stayed the same and it will not move from this cell (Fig. 5)

Absolute reference after dragging down
Fig. 5 Absolute ref­er­ence after drag­ging down

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

Data bars in a cell using character repeat

Today, we are going to talk about cre­at­ing charts like data bars in cells using for­mu­las. We want to cre­ate some­thing like this (Fig. 1)

Data bars in a cell using char­ac­ter repeat
Charts from data bars
Fig. 1 Charts from data bars

Let’s start with cre­at­ing a prop­er for­mu­la. We have to use the REPT (repeat) func­tion. It will repeat a text, one or more chars, as many times as we write in the sec­ond argu­ment. Let’s start with a pipe (a ver­ti­cal line). We want to repeat it as many times as there are sun­ny days in a giv­en month. Our for­mu­la looks like this (Fig. 2). 

=REPT(“|”,B2)

REPT formula with a pipe
Fig. 2 REPT for­mu­la with a pipe

After enter­ing and copy­ing down, we have data bars. How­ev­er, the dis­tance between indi­vid­ual signs is too big (Fig. 3) 

Data bars with too long distances
Fig. 3 Data bars with too long distances

We have to nar­row it by using, e.g. a dif­fer­ent font that works with this sign. We are select­ing our data bars and chang­ing the font name to Script (Fig. 4). Now, it looks much better. 

Font change
Fig. 4 Font change

Let’s try, how­ev­er, a dif­fer­ent font. With Bri­tan­ni­ca Bolt, the signs look like real data bars (Fig. 5). 

Font change again
Fig. 5 Font change again

Let’s take the last exam­ple, which is the Haet­ten­schweil­er font. In my opin­ion, it looks the best, so I’m stay­ing with this one (Fig. 6)

The best font
Fig. 6 The best font

Apart from repeat­ing a pipe, we can repeat oth­er signs. If they are wider than the pipe and if the num­ber of repeats is too big, we may have a prob­lem (Fig. 7)

=REPT(“*”,B2)

A formula with an asterisk
Fig. 7 A for­mu­la with an asterisk

We can see, that the aster­isk string is too long (Fig. 8)

Too long
Fig. 8 Too long

The solu­tion is divid­ing the num­ber, and the REPT func­tion will only look at the inte­ger part of the num­ber. Let’s divide our num­bers safe­ly by two (Fig. 9). 

=REPT(“*”,B2/2)

Number division
Fig. 9 Num­ber division

When there is a small­er num­ber of repeats, it looks quite good (Fig. 10) 

Shorter strings
Fig. 10 Short­er strings

We have to remem­ber that an aster­isk is a sim­ple sign, and we can use what­ev­er sign we like. Let’s take, for exam­ple, a star (Fig. 11) 

=REPT(“★”,B2/2)

A formula with a star
Fig. 11 A for­mu­la with a star

We can see that the strings are very long (Fig. 12). We can divide them by even a greater num­ber, e.g. 3. 

=REPT(“★”,B2/3)

Dividing by 3
Fig. 12 Divid­ing by 3

After putting the for­mu­la, it looks good (Fig. 13). 

Shorter strings
Fig. 13 Short­er strings

In our last exam­ple, we are going to repeat the let­ter n (Fig. 14)

=REPT(“n”,B2/3)

Repeating n
Fig. 14 Repeat­ing n

Now, we can see many ns (Fig. 15) 

N string
Fig. 15 N string

How­ev­er, we can change our font into Wind­ings, and the let­ter n changes into squares, which looks quite good as data bars (Fig. 16)

N into squares
Fig. 16 N into squares

Sum­ming, up, when we use dif­fer­ent signs and dif­fer­ent num­ber of repeats, we can cre­ate quite good data bars using a formula. 

https://www.youtube.com/watch?v=XYs6Eu-0hZw

Filtering multiple Pivot Tables at once using a slicer

Today, we are going to talk about how to fil­ter many piv­ot tables at once. We have three piv­ot tables based on the same dataset from the left (Fig. 1).

Fil­ter­ing mul­ti­ple Piv­ot Tables at once using a slicer
Three Pivot tables
Fig. 1 Three Piv­ot tables

If we want to fil­ter many piv­ot tables at once, we have to con­nect then into one slice. We have to select one cell from the first piv­ot table, then find the Pivot­Table Ana­lyze tab and Insert Slicer com­mand, where we want to add the slicer by Coun­try (Fig. 2)

Slicer by country
Fig. 2 Slicer by country

After press­ing OK, we have the slicer. We can change its size and col­or (Fig. 3).

Color and size change
Fig. 3 Col­or and size change

Now, we can fil­ter the first piv­ot table with the slicer. When we click on the name of a coun­try, we can see changes in the first piv­ot table (Fig. 4). How­ev­er, the sec­ond and the third piv­ot table did not change because they are not con­nect­ed to the slicer. 

Slicer for the first pivot table
Fig. 4 Slicer for the first piv­ot table

In order to con­nect then, we select the slicer, then we click on the Slicer tab, then the Report Con­nec­tion com­mand, which opens up a win­dow, where we can see three piv­ot tables. They have gener­ic, default names, and when we aren’t sure if they are the right ones, we can look which sheet they are locat­ed in. Then, we check prop­er check box­es to con­nect all piv­ot tables and press OK (Fig. 5)

Connecting three pivot tables
Fig. 5 Con­nect­ing three piv­ot tables

Now, we can see that the slicer is fil­ter­ing all, three, con­nect­ed piv­ot tables (Fig. 6)

Slicer for three pivot tables
Fig. 6 Slicer for three piv­ot tables

When the piv­ot table name or the sheet name is not enough to iden­ti­fy the right one, we can change their names. When you select a prop­er piv­ot table, go to the Piv­ot­Table Ana­lyze tab, then select the Piv­ot­Table Name com­mand, and write the name you want. Let’s write Piv­ot­Date (Fig. 7). Giv­ing names to piv­ot table makes it eas­i­er to work with them. 

Name change
Fig. 7 Name change

Now, that we have the slicer, we can eas­i­ly fil­ter three piv­ot tables at once (Fig. 8).

Ready slicer for three pivot tables
Fig. 8 Ready slicer for three piv­ot tables

https://www.youtube.com/watch?v=6TDXBG-wdhM

Remove unnecessary spaces — TRIM function

Today, we are going to remove unnec­es­sary spaces. Some­times, there’s a space at the begin­ning of text, some­times, there are more than one space between two words, and some­times, there are some spaces at the end. The last ones are the hard­est to notice (Fig. 1)

Remove unnec­es­sary spaces — TRIM function
Unnecessary spaces
Fig. 1 Unnec­es­sary spaces

The name in the first line, Brave Bran­don with a space at the end, is some­thing dif­fer­ent for Excel, than Brave Bran­don with­out a space. In such a case, we want to use the TRIM func­tion to remove the space (Fig. 2)

Trim function
Fig. 2 TRIM function

After copy­ing it down, we have our names with­out unnec­es­sary spaces (Fig. 3)

No unnecessary spaces
Fig. 3 No unnec­es­sary spaces

This sim­ple func­tion removes unnec­es­sary spaces from the begin­ning, the end, and the mid­dle of text beetween words only leaves one space. 

https://www.youtube.com/shorts/Pe8z-PthW6Q

Extract First Last and Middle Name with Formulas 

Today, we are going to talk about extract­ing first names, mid­dle names and last names from full names. We define the first name as the first word from the left, the last name as the first word from the right, and the mid­dle name, as every­thing between those two. Mid­dle names are a bit com­pli­cat­ed, as they can may con­sist of one word, a space, an abbre­vi­a­tion, or two or more words (Fig. 1)

Extract First Last and Mid­dle Name with Formulas
A list of names
Fig. 1 A list of names

Let’s start with extract­ing the first name. We just have to use the LEFT func­tion, which extracts signs from the left. We have to insert the FIND func­tion there, so that it finds the first space, and write the space in dou­ble quotes (Fig. 2)

=LEFT(A2,FIND(“ “,A2))

Extracting the first name
Fig. 2 Extract­ing the first name

Now, we have the first name (Fig. 3).

The first name
Fig. 3 The first name

But, we have to remem­ber that the FIND func­tion will return the posi­tion of the sign we’re look­ing for, which means that it finds the 7th posi­tion, which is a space (Fig. 4). 

7th position
Fig. 4 7th position

The first name , how­ev­er, con­sists of only 6 let­ters, which is what we want. It means that we want to extract less let­ters. So, we have write the for­mu­la once again, but this time we sub­tract one sign (Fig. 5)

=LEFT(A2,FIND(“ “,A2)-1)

Subtracting one sign
Fig. 5 Sub­tract­ing one sign

Now, we have only the first name with­out unnec­es­sary signs. After drag­ging it down, the whole col­umn is full (Fig. 6)

Full column
Fig. 6 Full column

Let’s go to last names. This case is a bit more com­pli­cat­ed. We don’t know whether we’re look­ing for the first, the sec­ond, the third or even a more dis­tant space (Fig. 7) 

Too many possible spaces
Fig. 7 Too many pos­si­ble spaces

There’s a trick to solve it. We have to repeat spaces. With­in our text, we have to sub­sti­tute a sin­gle space into many spaces, let’s say 29. We use the REPT func­tion (Fig. 8)

=SUBSTITUTE(A2,” “,REPT(“ “,29))

Repeating spaces
Fig. 8 Repeat­ing spaces

After accept­ing our func­tion, we have our changed names with many spaces between them (Fig. 9)

Names with many spaces
Fig. 9 Names with many spaces

Now, we can start extract­ing names from the right side. We’re extract­ing not only all signs from our name, but also the remain­ing 29 signs (Fig. 10).

=RIGHT(SUBSTITUTE(A2,” “,REPT(“ “,29)),29)

Extracting name and 29 signs
Fig. 10 Extract­ing name and 29 signs

Now, we have the last name and many, many spaces before it (Fig. 11)

Name with spaces
Fig. 11 Name with spaces

We have to delete them using the TRIM func­tion. The TRIM func­tion removes all spaces from a text string except for a sin­gle space between words. So, each space at the begin­ning and at the end of the string will be removed (Fig. 12)

=TRIM(RIGHT(SUBSTITUTE(A2,” “,REPT(“ “,29)),29))

Trimming unnecessary spaces
Fig. 12 Trim­ming unnec­es­sary spaces

After accept­ing it and copy­ing it down, we have our last names (Fig. 13). 

Last names
Fig. 13 Last names

Now, we have to find the thing between the first and the last name. We will use the SUBSTITUTE func­tion. In the place of the first name, we will place noth­ing, i.e. an emp­ty text string (Fig. 14). 

=SUBSTITUTE(A2,B2,“”)

Finding the middle name
Fig. 14 Find­ing the mid­dle name

Now, we have a short­er ver­sion of our name (Fig. 15).

Shorter version
Fig. 15 Short­er version

Let’s remove the last name now. We want to sub­sti­tute the last name with an emp­ty text string (Fig. 16)

=SUBSTITUTE(SUBSTITUTE(A2,B2,“”),D2,“”)

Removing the last name
Fig. 16 Remov­ing the last name

After enter­ing and copy­ing down, we have every­thing between the first name and the last name (Fig. 17). As you can see, we have also extract­ed spaces which we don’t need. So, let’s use the TRIM func­tion to delete unnec­es­sary spaces.

=TRIM(SUBSTITUTE(SUBSTITUTE(A2,B2,“”),D2,“”))

Unneeded spaces
Fig. 17 Unneed­ed spaces

Because we are edit­ing whole col­umn we can press Ctrl + Enter.

That’s how we extract first names, last names and every­thing in between with appro­pri­ate formulas. 

Final results
Fig. 18 Final results

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

Extract middle names with Flash Fill

Today, we are going to extract mid­dle names from full names. How­ev­er, not every­body has got a mid­dle name, so let’s start with the first and the last name. We can use here the Flash Fill option, which means that we just have to start writ­ing the first name, then anoth­er first name. After that, the Flash Fill com­mand does the work for us (Fig. 1).

Extract mid­dle names with Flash Fill
Using the Flash Fill option
Fig. 1 — Using the Flash Fill option

All we need to do is accept the results with Enter, and we have the first names (Fig. 2)

Entering the results
Fig. 2 — Enter­ing the results

We do the same with the last name, i.e., we start writ­ing the last name in the first cell, but this time we will force the Flash Fill option to work by press­ing the Ctrl + E key­board short­cut (Fig. 3).  This way, we have last names (Fig. 4)

 Flash Fill
Fig. 3 — Flash Fill
Flash Fill results
Fig. 4 — Flash Fill results

Now, the hard­est part – mid­dle names. We start writ­ing the mid­dle name in the first row, how­ev­er, we don’t have a mid­dle name in the sec­ond row. This time we’ll also use the Flash Fill option (Fig. 5)

Flash Fill for middle names
Fig. 5 — Flash Fill for mid­dle names

When all mid­dle names have been extract­ed, we can see an error. Edward isn’t a mid­dle name. We have to cor­rect the Flash Fill answer. We can do it, until the Flash Fill Options icon is show­ing up (Fig. 6).

Flash Fill icon
Fig. 6 — Flash Fill icon

We have to change the mid­dle name, which, in fact, isn’t a mid­dle name, for a dif­fer­ent mark, e.g. an excla­ma­tion mark. We sim­ply write the mark in the place of the error, press Enter, and the Flash Fill option will do its mag­ic again (Fig. 7) Excla­ma­tion marks are in the rows, where there aren’t mid­dle names.

 Exclamation marks
Fig. 7 — Excla­ma­tion marks

We can put almost any­thing in the place of the excla­ma­tion mark, e.g. a star (Fig. 8).

Stars
Fig. 8 — Stars

We usu­al­ly don’t want any stars or oth­er signs. We want to have blank cells, how­ev­er, the Flash Fill option doesn’t work  with spaces. That’s why we can use the Fil­ter option, which we can find in the Data tab (Fig. 9). In the Fil­ter option, we want to show only this sign (a star).

Filter option
Fig. 9 — Fil­ter option

Now, we’re left only with stars (Fig. 10). We have to select the range (Ctrl + Shift + ↓) and press the Delete key to delete all the signs.

Selected range
Fig. 10 — Select­ed range

Then we can turn off the fil­ter. We can do it man­u­al­ly, by press­ing the fil­ter icon and select­ing the Clear Fil­ter From “Mid­dle names” option (Fig. 11) or by press­ing the Ctrl + Shift + L key combination.

Turning off the filter
Fig. 11 — Turn­ing off the filter

Now, we have mid­dle names only in places, where they real­ly exist, and blank cells, where there aren’t any mid­dle names (Fig. 12)

Extracted names
Fig. 12 — Extract­ed names

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

IF function and logical tests

Today, we will dis­cuss log­i­cal tests and the IF func­tion in Excel. 

IF func­tion and log­i­cal tests

Let’s start with log­i­cal test. We want to check whether our stu­dents passed the test, i.e. whether they achieved 70 points (cell D2). We need a for­mu­la that checks if the num­ber from cell B5 is greater or equal to the val­ue from in cell D2. We aslo have to lock the val­ue from cell D2 by press­ing F4 key (Fig. 1). 

Logical test with locked cell D2
Fig. 1 — Log­i­cal test with locked cell D2 

After copy­ing the for­mu­la down, we have our log­i­cal answers (Fig. 2)

Logical answers
Fig. 2 — Log­i­cal answers

Log­i­cal answers, how­ev­er, aren’t human answers. If we want some­thing sim­pler, like pass/fail, we need to use the IF func­tion in cell D5 (Fig. 3). 

IF function inserting simpler answers
Fig. 3 — IF func­tion insert­ing sim­pler answers

After copy­ing it down, we have the answers that we want, instead of log­i­cal ones. If the log­i­cal test returns False, our IF func­tion returns text Fail. If the log­i­cal test returns True, our IF func­tion returns text Pass (Fig. 4)

Simpler/human answers
Fig. 4 — Simpler/human answers

Some­times, we want to know how many more points a stu­dent needs to pass their exam. In that case, we also use the IF func­tion. This time, how­ev­er, we are chang­ing the direc­tion of our test. We need to check if the val­ue from cell B5 is low­er than the val­ue from cell D2 (70 points). If it is low­er, it means that the stu­dent failed the exam. Cal­cu­lat­ing the num­ber of miss­ing points is a sim­ple, math­e­mat­i­cal oper­a­tion. We just have to sub­tract the val­ue from cell B5 (62 points) from the val­ue in cell D2 (70 points). How­ev­er, if a stu­dent passed the exam, we don’t need to cal­cu­late any­thing, so we’re return­ing 0 points (Fig. 5). 

=IF(B5<$D$2,$D$2‑B5,0)

IF function calculating the number of missing points
Fig. 5 — IF func­tion cal­cu­lat­ing the num­ber of miss­ing points

After copy­ing it down, we can see that one stu­dent needs 8 points to pass, and anoth­er one needs 35. The stu­dents who passed the exam, don’t need any more points, that’s why IF func­tion returned 0 for them (Fig. 6). 

The number if missing points
Fig. 6 — The num­ber if miss­ing points

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