Excel and Google Sheets how-to
Take the first, last or middle characters from a cell
A SKU like MG-012-RED packs three facts into one cell: the product type, how many come in a box and the colour. LEFT, RIGHT and MID take each piece out by its position.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | SKU | Boxes | Type | Per box | Colour |
| 2 | MG-012-RED | 3 | MG | 012 | RED |
| 3 | MG-024-BLU | 2 | MG | 024 | BLU |
| 4 | TS-006-BLK | 5 | TS | 006 | BLK |
| 5 | PN-100-BLU | 1 | PN | 100 | BLU |
| 6 | TS-012-WHT | 4 | TS | 012 | WHT |
Sample data. SKUs in A, boxes in stock in B, the formulas in C2, D2 and E2 filled down to row 6.
The first characters: LEFT
Click C2 and type:
=LEFT(A2,2)Fill it down to C6: MG, MG, TS, PN, TS. LEFT takes the number of characters you ask for from the start of the cell.
- Leave the number out and you get one character. Microsoft's LEFT page: "If num_chars is omitted, it is assumed to be 1." So =LEFT(A2) gives M.
- Ask for more than the cell holds and you get the whole cell, not an error: "If num_chars is greater than the length of text, LEFT returns all of text." =LEFT(A2,20) gives MG-012-RED.
Google Sheets works the same way. Its LEFT page gives LEFT(string, [number_of_characters]), with 1 by default.
The last characters: RIGHT
In E2:
=RIGHT(A2,3)Filled down: RED, BLU, BLK, BLU, WHT. RIGHT counts from the end of the cell, with the same two rules as LEFT on Microsoft's RIGHT page.
The middle: MID
In D2:
=MID(A2,4,3)That says: start at character 4 and take 3. M, G and the dash are characters 1 to 3, so the result is 012. Filled down: 012, 024, 006, 100, 012.
MID always needs all three parts: the cell, where to start and how many to take. Taking more than is left is fine. Microsoft's MID page says that when the start plus the count runs past the end, "MID returns the characters up to the end of text", so =MID(A2,8,10) gives RED. Google's MID page says the same.
The result is text, not a number
The Per box column shows 012 with its zero, on the left of the cell where text goes, because LEFT, RIGHT and MID always give text. That matters when you add up: =SUM(D2:D6) gives 0, because SUM skips text (more on the SUM says 0 page). VALUE turns it into a number:
=VALUE(MID(A2,4,3))That gives 12. Microsoft's VALUE page: it "Converts a text string that represents a number to a number." To get the units in stock, multiply by the boxes:
=VALUE(MID(A2,4,3))*B2That gives 36, 48, 30, 100 and 48 down the column. The same page also says "Excel automatically converts text to numbers as necessary", so =MID(A2,4,3)*B2 gives 36 too: it is SUM and its cousins that skip text. All the units in one cell:
=SUMPRODUCT(VALUE(MID(A2:A6,4,3)),B2:B6)That gives 262. One catch: VALUE drops the leading zero, so 012 becomes 12. When the piece is a code that must keep its zeros, leave it as text. The leading zeros page has more.
When the parts change length
MID by position only works while every SKU has the same shape. With MG-12-RED, PN-100-BLU, TS-6-BLK and CUP-24-GRN, =MID(A2,4,3) gives 12-, 100, 6-B and -24. Split at the dashes instead. In Excel for Microsoft 365, Excel for the web and Excel 2024:
=TEXTBEFORE(A2,"-")=TEXTBEFORE(TEXTAFTER(A2,"-"),"-")=TEXTAFTER(A2,"-",-1)They give MG, 12 and RED for the first SKU, and CUP, 24 and GRN for the last. TEXTAFTER(A2,"-") is everything after the first dash, 12-RED, and TEXTBEFORE takes the part before the next dash. The -1 in the last one counts from the end; Microsoft's TEXTAFTER page: "A negative number starts searching text from the end." A SKU with no dash gives #N/A by default (TEXTBEFORE page).
Older Excel and Google Sheets: FIND gives the position of the dash, and LEFT and MID cut there:
=LEFT(A2,FIND("-",A2)-1)=MID(A2,FIND("-",A2)+1,FIND("-",A2,FIND("-",A2)+1)-FIND("-",A2)-1)=MID(A2,FIND("-",A2,FIND("-",A2)+1)+1,100)FIND("-",A2,FIND("-",A2)+1) starts looking one character after the first dash, so it finds the second one: 6 in MG-12-RED. The 100 means "up to 100 characters", more than any SKU needs. Wrap the middle one in VALUE before you multiply or add. For names, the split a full name page uses the same idea with a space.
A number in front of a unit
When a cell says 12 kg and the price per kg is in B2, take everything before the space and multiply:
=LEFT(A2,FIND(" ",A2)-1)*B212 kg at 3.5 gives 42, 7.5 kg at 2 gives 15 and 40 kg at 0.8 gives 32. The number can be any length, because FIND looks for the space. In Excel for Microsoft 365, Excel for the web and Excel 2024, =TEXTBEFORE(A2," ")*B2 does the same.
A date gives odd digits
With 18 Nov 2026 in A2, =LEFT(A2,3) gives 463, not 18 N. Microsoft's DATE page: "Excel stores dates as sequential serial numbers so that they can be used in calculations." 18 Nov 2026 is 46344, and LEFT reads those digits, not what the cell shows. Prices work the same way: with $1,234.50 in A3, =LEFT(A3,3) gives 123, because the cell holds 1234.5. For a piece of a date, use the date functions instead:
=YEAR(A2)=TEXT(A2,"mmm")They give 2026 and Nov. Both work in Excel and Google Sheets.
A space in front
Data pasted from a web page or an export often starts with a space, and LEFT counts it: " Toronto" gives " To" for =LEFT(A2,3). TRIM takes the space off first:
=LEFT(TRIM(A2),3)That gives Tor. The extra spaces page covers spaces TRIM cannot remove.
Without a formula: Flash Fill
In Excel, type the first answer next to the first row, MG next to MG-012-RED, then click the cell below it. Microsoft's Flash Fill page: "Go to Data > Flash Fill, or press Ctrl+E." Excel fills the rest of the column from the pattern. The filled cells hold plain values, not formulas, so run it again when the SKUs change, and read the column before you trust it.
Free practice sheet
Three jobs for a candle shop's stock list: the product type and the scent from each SKU with LEFT and RIGHT; the pieces in stock with VALUE and MID; and the pack size from SKUs whose parts change length, where MID by position gets most rows wrong. Yellow cells for you, a Check column that says Correct or Try again, and an Answers tab. One Excel file that opens in Google Sheets too. Free, no sign up. Sample data.
Download the practice sheet (.xlsx)
Templates with the math already done
Rather skip the formulas? These templates come with every formula built and checked, plus a filled-in sample.
- Inventory SpreadsheetStock on hand from a moves log, reorder flags at your reorder point, order cost and stock value.
- Reseller Inventory and Profit TrackerOne running inventory list from purchase to sale, with profit per item.
- Handmade Product Pricing CalculatorEnter what your materials cost, how long each item takes and what your marketplace charges.
Teaching this to a class or team?
More how-tos
- Find a price by its code with XLOOKUPType a product code, get its price back from your price list. One formula, no helper columns.
- Total each category with SUMIFSAdd up all the Fuel, all the Office, all the Meals: one formula per category, and more rules when you need them.
- Check two conditions at once with IF and ANDFree shipping only when the order is 50 or more and ships in Canada: one IF, one AND, done.
- Add leading zeros to numbersType 00021 and Excel or Google Sheets shows 21, because to them it is just the number 21. Here is how to get the zeros back, and keep them.
- Fix #DIV/0! in an averageAn average of nothing is a division by zero, so AVERAGE shows #DIV/0! until the first number arrives. One IF fixes it.
- Count rows that meet two conditions with COUNTIFSHow many of Ana's deals were 500 or more? COUNTIFS answers it in one cell, and takes as many rules as you need.
- Calculate percentage changeSales went from 400 to 500. That is a 25% increase, and one short formula works it out for every row.
- Calculate years of service from a start dateAna started on 15 March 2019. How many full years has she worked? DATEDIF counts them, and the same formula works out an age from a date of birth.
- Combine first and last name into one cellFirst names in one column, last names in the next, and you need "Ana Lopez" in one cell. The & sign joins them.
- Find duplicates in a list with COUNTIFA mailing list where some people signed up twice. One formula shows how many times each email appears, so the repeats stand out.
- Split a full name into first and last nameYour list has "Ana Lopez" in one cell and you need Ana and Lopez in two. Two short formulas find the space and split there.
- Total amounts by month with SUMIFSA list of dated expenses and you want one total per month. SUMIFS adds every amount between the first and the last day of the month.
- Count working days between two datesAna is off from 1 Oct to 14 Oct. How many working days is that? NETWORKDAYS counts Monday to Friday and leaves out the weekends.
- Hide #N/A in VLOOKUP with IFERRORYour order list has a code that is not in the price list, and VLOOKUP shows #N/A. IFERROR puts your own words there instead.
- Count cells that contain textA stock list where some items have a note and most do not. One COUNTIF with an asterisk counts the notes and skips the empty cells.
- Make a running total (cumulative sum)Monthly sales in one column, the total so far in the next. One formula, filled down.
- Round to 2 decimal places, up or downA 15% discount turns 12.99 into 11.0415. ROUND makes it 11.04 and keeps your totals right to the cent. ROUNDUP and ROUNDDOWN handle the times when nearest is the wrong answer.
- How long to $1,000,000? FV and NPERPut $500 a month away at an example 7% a year. FV says what it grows to, NPER says when it passes $1,000,000. Two formulas, no calculator site.
- Why your formula gives the wrong number: the order of operationsA2 holds 10 and A3 holds 4. What does =A2-A3*2 give? It is 2, not 12. The same rule explains most formulas that look right and give the wrong number.
- Why your SUM says 0, and how to fix itThe amounts are right there in the column, and the total says 0. They look like numbers, but the sheet has them stored as text, and SUM skips text.
- Fill handle not working? Copy a formula down fastYou wrote one formula and need it in every row. Here are the quick ways to copy it down, and what to check when the fill handle will not show up or the copies come out wrong.
- Calculate hours worked from start and end timesA shift from 9:00 to 17:30 is 8.5 hours, but subtract the times and the cell shows 8:30. One small change turns it into a number you can add up and multiply by a pay rate.
- IF a cell is blank, or not blankYou want a formula to do one thing when a cell is empty and something else when it is filled. Two double quotes do the job, and they also catch the blanks ISBLANK misses.
- Formulas not updating? Recalculate and refreshYou change a number and the total does not move. It is nearly always one of a handful of things, and each one takes seconds to fix once you know which.
- Standard deviation in Excel and Google SheetsTwo shops both average 40 orders a day. One sells 38 to 42 every day; the other swings from 25 to 55. The average cannot tell them apart. The standard deviation can.
- Stack several columns into one column with TOCOLNames in three columns, one for each day, and you need them in one list. One formula does it, and the list keeps up when the columns change.
- Long numbers turn into E+ or end in 0 in ExcelYou type a 12 digit order number and Excel shows 5.93774E+11. You type a 16 digit account number and the last digit turns into 0. The first one is only how the cell looks. The second is a real loss, and it has to be stopped before you type.
- Count how many times each value appears in a columnA staff list with a department on every row, and you need to know how many people are in each department. Two short formulas build the count table, and it keeps up when the list changes.
- Freeze rows and columns so the headers stay on screenMonths across the top, names down the side, and once you scroll a little both slide away and you lose track of whose row you are reading. Freezing keeps them on screen while the rest of the sheet moves.
- Highlight a whole row with a conditional formatting formulaAn order list where you want every late order to stand out, the whole row and not just the Status cell. One rule with a short formula does it, and it keeps working as statuses change.
- Remove extra spaces in Excel and Google Sheets with TRIMNames that will not sort right, a VLOOKUP that says #N/A for a code you can see in the list, two cells that look the same but do not match: a space you cannot see is often the cause. TRIM fixes most of them, and one more step fixes the rest.
- Create a drop-down list in Excel and Google SheetsA Status column where one person types Paid, another types payed and a third types Done is hard to count or filter. A drop-down list lets people pick from your choices instead, and it takes a minute to set up.
- Check if a cell contains a word in Excel and Google SheetsAn item list where you want every row with pen in it marked, added up or pulled out. =A2="pen" only finds a cell that is exactly pen, so the work goes to SEARCH, which looks inside the text.
- Free pricing calculatorsPrice a job from your real costs and margin. No sign up.
- Free downloadsPractice sheets and printable pages, no email and no sign up.







