Workbooks and worksheets
Excel works with files called workbooks. Each workbook contains one or more spreadsheets, called worksheets. Each worksheet consists of cells organized in a rectangular grid. The rows of a worksheet are labeled with a number and the columns are labeled with a letter or series of letters. The first row is labeled 1, the next 2, and so on. The first column is labeled A, the next B, etc. The column after Z is labeled AA, and then AB, AC, and so on. The column after AZ is BA, and then BB, BC, etc. The column after ZZ is AAA, and then AAB, AAC, etc.
Figure 1 – Sample Excel Worksheet
Each worksheet can contain up to 1,048,578 rows and 16,384 columns (i.e. column A through XFD).
Cell values, addresses and ranges
You can enter any of the following into a cell:
- A number (e.g. 45 or -23.006)
- Text (e.g. London)
- A truth value (TRUE or FALSE)
- A formula (e.g. =SUM(A4:B7)/4)
Numeric values can also appear in scientific notation: e.g. the value 4.5E-05 is equivalent to .000045 (i.e. 4.5 with the decimal point moved 5 places to the left) and 4.5E+05 is equivalent to 450000 (i.e. 4.5 with the decimal point moved 5 places to the right).
If you want Excel to treat a number as text then you need to precede the number with a single quote – e.g. ‘4.5 is considered to be the text 4.5.
Cell references
Each cell also has an address, consisting of a row and a column label. E.g., in Figure 1 the cell with address A5 contains the text “London”, while the cell with address C6 contains the number 8.1.
You can also reference a range of cells. For our purposes, we only consider rectangular ranges, which consist of a rectangular collection of cells. Such ranges are specified as two cell addresses separated by a colon. E.g. the range C5:C10 consists of the 5 cells from cell C5 to C10, which for Figure 1 corresponds to the data elements for Brand B. The range A4:D10 consists of all the cells in the rectangle whose opposite corners are A4 and D10, which for Figure 2.1 corresponds to all the data in the table, including row and column headings, but excluding totals.
A cell reference consists of an address of a single cell (e.g. G17 or AB8) or of a cell range (e.g. A1:D6 or ZZ1:AAB14). Cell references can also be named. E.g. you can highlight the range B5:D5 in the worksheet in Figure 1, right-click and select Define Name … to assign the name London to the range B5:D5.
Cell selection
The usual way of selecting a cell is to simply move the mouse pointer to that cell and left-click. To select a range of cells, click on a cell in one of the four corners of that range and then highlight the remaining cells in the range using the mouse. If the cells you want to select are not visible you can use the horizontal and vertical scroll bars in the usual manner to make the desired cell range visible.
Increasing cell width
If the contents of a cell are too big for the space allocated to that cell you may see the contents displayed as #######. To properly see the real contents you may need to increase the width of the column containing this cell.
E.g. suppose cell B5 is not wide enough for its contents. You can increase the width of column B by moving the mouse pointer to the vertical line at the border between the headers for column B and column C (the column to the right of B). Once it is in the correct position the mouse pointer changes shape; now hold down the left mouse button and move the mouse pointer to the right to increase the column width (or left to decrease the column width). You can also change the width of a column by right-clicking on the column heading and selecting the Column Width… option.
Formulas
As mentioned above, besides numbers and text, cells can contain formulas. Formulas are built up from the following components preceded by the equal symbol (=):
- Numbers
- Text
- Operators
- Cell references
- Worksheet functions
Operators include the following:
- Arithmetic operators: addition (+), subtraction (-), multiplication (*), division (/) and exponentiation (^)
- The concatenation operator: & (used to concatenate text)
- Logical comparison operators: less than (<), greater than (>), less than or equal (<=), greater than or equal (>=), equal (=) and not equal (<>)
Precedence rules
The usual precedence rules apply, namely multiplication and division are applied before addition and subtraction, and exponentiation is applied before any of the other operators. Parentheses are used to change the order in which operators are applied. For example:
4+5*2 = 14 (4+5)*2 = 18
3^2-1 = 8 3^(2-1) = 3
-(3^2)+1 = -8 (-3)^2+1 = 10
For some reason, Excel violates the usual precedence rules by giving a unary minus sign precedence over exponentiation. E.g. Excel calculates -3^2+1 as if it were (-3)^2+1 and so returns a value of 10 instead of -8. Similarly, -1^2 is evaluated as 1 instead of -1. To get the correct answer you need to use the expression -(1^2).
Excel provides a variety of worksheet functions such as SUM, MIN, LOG, etc. We will describe these in more detail shortly.
Cell values
Each cell has a value. For cells containing a number, text, or truth value, the value of the cell is simply the contents of the cell. For cells containing a formula, the value is the evaluation of the formula based on the values of any referenced cells. Some examples of the values of formulas are given in Figure 2.
Figure 2 – Values of Excel Formulas
In the example in Figure 1, notice that cell B11 contains the formula =SUM(B5:B10). The value of this formula, and therefore the value of cell B11, is 106.1. This is the value that is actually displayed in the cell. The formula is displayed in the Formula Bar, just above the grid, to the right of the symbol fx.
Note too that if we had assigned the name BrandA to the range B5:B10, then the formula =SUM(BrandA) would be equivalent to =SUM(B5:B10) and would have the same value.
Specifying a formula
In specifying a formula such as =A1+3 you can simply type the formula character by character. Alternatively, you can type the character = and click on the A1 cell and then continue by typing +3. Excel will automatically specify the correct formula. Similarly, for a formula that contains a cell range such as =SUM(A1:B4) you can type =SUM( and highlight the cell range A1:B4 and then type the right parenthesis to complete the formula.
Error values
If a cell has an illegal value you will see an error value displayed in the cell. E.g., if you enter =A1/0 into cell B1 then cell B1 will have the value #DIV/0 indicating that you are attempting to divide by zero. These error values all start with the symbol # and include #DIV/0, #N/A, #NUM!, #VALUE!, #NAME?, #NULL! and #REF!
Observations
One of the things that gives Excel such power is that when you change the value of any cell then the value of all formulas that reference that cell also change. E.g., if you change the value of cell B5 in the worksheet in Figure 1 from 23.5 to 13.5 then the value of cell B11 will automatically change from 106.1 to 96.1.
You can copy the contents of any cell into another cell (or, in fact, any cell range into another cell range, usually of the same size and shape). If the content of the first cell is a number, text or truth value, then the second cell will contain the same number, text, or truth value. When the contents of the first cell is a formula then the second cell will also contain a formula, but the specific formula depends on the type of addressing that is used.
Relative and absolute addressing
Excel provides two types of addressing when defining a cell or cell range: absolute and relative addressing. The default is relative addressing. For example, the contents of cell B11 in the worksheet in Figure 1 is =SUM(B5:B10). Here B5:B10 is a relative address. If this formula is copied into cell D11, then D11 will contain the formula =SUM(D5:D10), which accomplishes the same function as the formula in cell B11, namely to sum the values in the 5 cells above it, and so the value of cell D11 will be 43.3.
The usual way of copying the contents of one cell into another is to click on the first cell (B11 in the example above), press Ctrl-C (copy), and then click on the second cell (D11 in the example above) and press Ctrl-V (paste).
The dollar symbol $ is used to specify absolute addressing. When copying a formula that contains a dollar sign to another cell location, any part of an address that contains a $ does not change. E.g., suppose cell B11 in the worksheet from Figure 1 contains the formula =SUM($B$5:$B$10). Its value is still the same, namely 106.1, but this time when we copy the contents of cell B11 into D11, then D11 will also contain the formula =SUM($B$5:$B$10), and so the value of cell D11 will be 106.1 and not 43.3.
Note that we can use absolute addressing on any part of a cell address, namely, B11 (no absolute addressing), B$11 (absolute addressing for the row, but relative addressing for the column), $B11 (absolute addressing for the column, but relative addressing for the row) and $B$11 (absolute addressing for both row and column).
Changing addressing type
To change from relative addressing (the default) to absolute addressing, you simply put the $ symbol in the appropriate place. Alternatively, you can highlight the cell address in the Formula Bar or in the cell itself and press the function key F4. E.g. if you highlight the cell reference A3 and press the F4 key, then A3 changes to $A$3. If you press F4 again it changes to A$3. Pressing F4 again changes the reference to $A3, and finally pressing F4 one more time returns the cell address to the original reference of A3.
Cell references to a different worksheet
You can also reference cells in another worksheet. To do this you need to precede the reference (absolute or relative) by the name of the worksheet followed by !. The default names for worksheets in Excel are Sheet1, Sheet2, etc., although these names can be changed as explained below. Thus the (relative) reference to range A3:B4 in Sheet1 is Sheet1!A3:B4. You don’t really need to worry about all of this since by clicking on a cell in another worksheet, Excel automatically copies the correct reference address into the formula.
References
Walkenbach, J. (2010) Microsoft Office Excel 2010 Bible. Wiley.
GCF Global (2022) Excel formulas
https://edu.gcfglobal.org/en/excelformulas/
In this post we’ll find out how to get a list of all the sheet names in the current workbook without using VBA.
This can be pretty handy if you have a large workbook with hundreds of sheets and you want to create a table of contents. This method uses the little known and often forgotten Excel 4 macro functions.
These functions aren’t like Excel’s other functions such as SUM, VLOOKUP, INDEX etc. These functions won’t work in a regular sheet, they only work in named functions and macro sheets. For this trick we’re going to use one of these in a named function.
In this example, I’ve created a workbook with a lot of sheets. There are 50 sheets in this example so I was lazy and didn’t rename them from the default names.
Now we will create our named function.
- Go to the Formulas tab.
- Press the Define Name button.
- Enter SheetNames into the name field.
- Enter the following formula into the Refers to field.
=REPLACE(GET.WORKBOOK(1),1,FIND("]",GET.WORKBOOK(1)),"")
- Hit the OK button.
In a sheet within the workbook enter the numbers 1,2,3,etc… into column A starting at row 2 and then in cell B2 enter the following formula and copy and paste it down the column until you have a list of all your sheet names.
=INDEX(SheetNames,A2)
As a bonus, we can also create a hyperlink so that if you click on the link it will take you to that sheet. This can be handy for navigating through a spreadsheet with lots of sheets. To do this add this formula into the column C.
= HYPERLINK ( "#'" & B2 & "'!A1", "Go To Sheet" )
Note, to use this method you will need to save the file as a macro enabled workbook (.xls, .xlsm or .xlsb). Not too difficult and no VBA needed.
Video Tutorial
This video will show you two methods to list all the sheet names in a workbook.
- The first method uses a VBA procedure from this post.
- The second (skip to 3:15 in the video) uses the method in the above post.
About the Author
John is a Microsoft MVP and qualified actuary with over 15 years of experience. He has worked in a variety of industries, including insurance, ad tech, and most recently Power Platform consulting. He is a keen problem solver and has a passion for using technology to make businesses more efficient.
Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel 2010 Excel 2007 Excel for Mac 2011 More…Less
Each time you create a table, Excel assigns a default name to the table according to this naming convention: Table1, Table2, Table3, and so on. To make it easier to refer to a table, for example, in a workbook that contains many tables, you can name each table.
Note: The screen shots in this article were taken in Excel 2016. Your view may differ slightly if you have a different version of Excel, but the functionality is the same (unless otherwise noted).
To rename a table:
-
Click on the table.
-
Go to Table Tools > Design > Properties > Table Name.
On a Mac, go to the Table tab > Table Name.
-
Highlight the table name and enter a new name.
Tips:
-
All of your tables will be shown in the Address bar, which appears to the left of the Formula bar. When you select any table from the list, Excel will automatically jump to that table—even if it’s on another worksheet.
-
Important notes for names
-
Use valid characters — Always begin a name with a letter, an underscore character (_), or a backslash (). Use letters, numbers, periods, and underscore characters for the rest of the name.
Exceptions: You can’t use «C», «c», «R», or «r» for the name, because they’re already designated as a shortcut for selecting the column or row for the active cell when you enter them in the Name or Go To box.
-
Don’t use cell references — Names can’t be the same as a cell reference, such as Z$100 or R1C1.
-
Don’t use a space to separate words — Spaces cannot be used in the name. Consider how you can write the name using no spaces. Or, use an underscore character (_) or a period (.) as word separators. Examples: DeptSales, Sales_Tax or First.Quarter.
-
Maximum 255 characters — A table name can have up to 255 characters.
-
Use unique table names — Duplicate names aren’t allowed. Excel doesn’t distinguish between upper and lowercase characters in names, so if you enter “Sales” but already have another name called “SALES» in the same workbook, you’ll be prompted to choose a unique name.
Rename a table in Excel for the web
Note: This is one of several beta features, and currently only available to a portion of Office Insiders at this time. We’ll continue to optimize these features over the next several months. When they’re ready, we’ll release them to all Office Insiders, and Microsoft 365 subscribers.
-
Click on the table.
-
On the Table Design tab, double-click the Table Name, and then enter a new name.
Need more help?
You can always ask an expert in the Excel Tech Community or get support in the Answers community.
See Also
Overview of Excel tables
Video: Create an Excel table
Total the data in an Excel table
Resize a table by adding or removing rows and columns
Excel table compatibility issues
Export an Excel table to SharePoint
Convert an Excel table to a range
Filter data in a range or table
Need more help?
Want more options?
Explore subscription benefits, browse training courses, learn how to secure your device, and more.
Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.
I have loaded a workbook into R and read in the worksheets using xlConnect, but I was wondering if there was a way of extracting the names of the sheets perhaps in a vector?
So far my code is:
dataIn<-loadWorkbook(file.path(filenames[1],sep=""))
lst = readWorksheet(dataIn, sheet = getSheets(dataIn), startRow=1, startCol=1, header=TRUE)
…and I want to extract the sheet names of the sheets in lst
.
Mogsdad
44.3k21 gold badges151 silver badges272 bronze badges
asked Jul 30, 2013 at 10:39
1
Another really nice package developed by the folks at RStudio is readxl
. It’s easy to get the excel sheet names with the excel_sheets()
function.
library(readxl)
path <- "path/to/your/file.xlsx"
excel_sheets(path = path)
answered Jul 1, 2017 at 10:45
Matt DanchoMatt Dancho
6,5903 gold badges33 silver badges25 bronze badges
1
You are looking for getSheets
Returns all worksheet names in a workbook.
answered Jul 30, 2013 at 10:50
agstudyagstudy
119k17 gold badges196 silver badges259 bronze badges
0
In the «openxlsx» package it would be a command «getSheetNames»:
library(openxlsx)
path <- "path/to/your/file.xlsx"
getSheetNames(path)
answered Dec 27, 2019 at 15:26
LukerLuker
1112 silver badges4 bronze badges