How to get the row or column number of the current cell or any other cell in Excel.
This tutorial covers important functions that allow you to do everything from alternate row and column shading to incrementing values at specified intervals and much more.
We will use the ROW and COLUMN function for this. Here is an example of the output from these functions.
Though this doesn’t look like much, these functions allow for the creation of powerful formulas when combined with other functions. Now, let’s look at how to create them.
Get a Cell’s Row Number
Syntax
This function returns the number of the row that a particular cell is in.
If you leave the function empty, it will return the row number for the current cell in which this function has been placed.
If you put a cell reference within this function, it will return the row number for that cell reference.
This example would return 1 since cell A1 is in row 1. If it was =ROW(C24) the function would return the number 24 because cell C24 is in row 24.
Examples
Now that you know how this function works, it may seem rather useless. Here are links to two examples where this function is key.
Increment a Value Every X Number of Rows in Excel
Shade Every Other Row in Excel Quickly
Get a Cell’s Column Number
Syntax
This function returns the number of the column that a particular cell is in. It counts from left to right, where A is 1 and B is 2 and so on.
If you leave the function empty, it will return the column number for the current cell in which this function has been placed.
If you put a cell reference within this function, it will return the column number for that cell reference.
This example would return 1 since cell A1 is in row 1. If it was =COLUMN (C24) the function would return the number 3 because cell C24 is in column number 3.
Examples
The COLUMN function works just like the ROW function does except that it works on columns, going left to right, whereas the ROW function works on rows, going up and down.
As such, almost every example where ROW is used could be converted to use COLUMN based on your needs.
Notes
The ROW and COLUMN functions are building blocks in that they help you create more complex formulas in Excel. Alone, these functions are pretty much worthless, but, if you can memorize them and keep them for later, you will start to find more and more uses for them when working in large data sets. The examples provided above in the ROW section cover only two of many different ways you can use these functions to create more powerful and helpful spreadsheets.
Similar Content on TeachExcel
Sum Values from Every X Number of Rows in Excel
Tutorial: Add values from every x number of rows in Excel. For instance, add together every other va…
Formulas to Remove First or Last Character from a Cell in Excel
Tutorial: Formulas that allow you to quickly and easily remove the first or last character from a ce…
Formula to Delete the First or Last Word from a Cell in Excel
Tutorial:
Excel formula to delete the first or last word from a cell.
You can copy and paste the fo…
Reverse the Contents of a Cell in Excel — UDF
Macro: Reverse cell contents with this free Excel UDF (user defined function). This will mir…
Excel Function to Remove All Text OR All Numbers from a Cell
Tutorial: How to create and use a function that removes all text or all numbers from a cell, whichev…
Get the First Word from a Cell in Excel
Tutorial: How to use a formula to get the first word from a cell in Excel. This works for a single c…
Subscribe for Weekly Tutorials
BONUS: subscribe now to download our Top Tutorials Ebook!
Watch Video – 7 Quick and Easy Ways to Number Rows in Excel
When working with Excel, there are some small tasks that need to be done quite often. Knowing the ‘right way’ can save you a great deal of time.
One such simple (yet often needed) task is to number the rows of a dataset in Excel (also called the serial numbers in a dataset).
Now if you’re thinking that one of the ways is to simply enter these serial number manually, well – you’re right!
But that’s not the best way to do it.
Imagine having hundreds or thousands of rows for which you need to enter the row number. It would be tedious – and completely unnecessary.
There are many ways to number rows in Excel, and in this tutorial, I am going to share some of the ways that I recommend and often use.
Of course, there would be more, and I will be waiting – with a coffee – in the comments area to hear from you about it.
How to Number Rows in Excel
The best way to number the rows in Excel would depend on the kind of data set that you have.
For example, you may have a continuous data set that starts from row 1, or a dataset that start from a different row. Or, you might have a dataset that has a few blank rows in it, and you only want to number the rows that are filled.
You can choose any one of the methods that work based on your dataset.
1] Using Fill Handle
Fill handle identifies a pattern from a few filled cells and can easily be used to quickly fill the entire column.
Suppose you have a dataset as shown below:
Here are the steps to quickly number the rows using the fill handle:
Note that Fill Handle automatically identifies the pattern and fill the remaining cells with that pattern. In this case, the pattern was that the numbers were getting incrementing by 1.
In case you have a blank row in the dataset, fill handle would only work till the last contiguous non-blank row.
Also, note that in case you don’t have data in the adjacent column, double-clicking the fill handle would not work. You can, however, place the cursor on the fill handle, hold the right mouse key and drag down. It will fill the cells covered by the cursor dragging.
2] Using Fill Series
While Fill Handle is a quick way to number rows in Excel, Fill Series gives you a lot more control over how the numbers are entered.
Suppose you have a dataset as shown below:
Here are the steps to use Fill Series to number rows in Excel:
This will instantly number the rows from 1 to 26.
Using ‘Fill Series’ can be useful when you’re starting by entering the row numbers. Unlike Fill Handle, it doesn’t require the adjacent columns to be filled already.
Even if you have nothing on the worksheet, Fill Series would still work.
Note: In case you have blank rows in the middle of the dataset, Fill Series would still fill the number for that row.
3] Using the ROW Function
You can also use Excel functions to number the rows in Excel.
In the Fill Handle and Fill Series methods above, the serial number inserted is a static value. This means that if you move the row (or cut and paste it somewhere else in the dataset), the row numbering will not change accordingly.
This shortcoming can be tackled using formulas in Excel.
You can use the ROW function to get the row numbering in Excel.
To get the row numbering using the ROW function, enter the following formula in the first cell and copy for all the other cells:
=ROW()-1
The ROW() function gives the row number of the current row. So I have subtracted 1 from it as I started from the second row onwards. If your data starts from the 5th row, you need to use the formula =ROW()-4.
The best part about using the ROW function is that it will not screw up the numberings if you delete a row in your dataset.
Since the ROW function is not referencing any cell, it will automatically (or should I say AutoMagically) adjust to give you the correct row number. Something as shown below:
Note that as soon as I delete a row, the row numbers automatically update.
Again, this would not take into account any blank records in the dataset. In case you have blank rows, it will still show the row number.
You can use the following formula to hide the row number for blank rows, but it would still not adjust the row numbers (such that the next row number is assigned to the next filled row).
IF(ISBLANK(B2),"",ROW()-1)
4] Using the COUNTA Function
If you want to number rows in a way that only the ones that are filled get a serial number, then this method is the way to go.
It uses the COUNTA function that counts the number of cells in a range that are not empty.
Suppose you have a dataset as shown below:
Note that there are blank rows in the above-shown dataset.
Here is the formula that will number the rows without numbering the blank rows.
=IF(ISBLANK(B2),"",COUNTA($B$2:B2))
The IF function checks whether the adjacent cell in column B is empty or not. If it’s empty, it returns a blank, but if it’s not, it returns the count of all the filled cells till that cell.
5] Using SUBTOTAL For Filtered Data
Sometimes, you may have a huge dataset, where you want to filter the data and then copy and paste the filtered data into a separate sheet.
If you use any of the methods shown above so far, you will notice that the row numbers remain the same. This means that when you copy the filtered data, you will have to update the row numbering.
In such cases, the SUBTOTAL function can automatically update the row numbers. Even when you filter the data set, the row numbers will remain intact.
Let me show you exactly how it works with an example.
Suppose you have a dataset as shown below:
If I filter this data based on Product A sales, you will get something as shown below:
Note that the serial numbers in Column A are also filtered. So now, you only see the numbers for the rows that are visible.
While this is the expected behavior, in case you want to get a serial row numbering – so that you can simply copy and paste this data somewhere else – you can use the SUBTOTAL function.
Here is the SUBTOTAL function that will make sure that even the filtered data has continuous row numbering.
=SUBTOTAL(3,$B$2:B2)
The 3 in the SUBTOTAL function specifies using the COUNTA function. The second argument is the range on which COUNTA function is applied.
The benefit of the SUBTOTAL function is that it dynamically updates when you filter the data (as shown below):
Note that even when the data is filtered, the row numbering update and remains continuous.
6] Creating an Excel Table
Excel Table is a great tool that you must use when working with tabular data. It makes managing and using data a lot easier.
This is also my favorite method among all the techniques shown in this tutorial.
Let me first show you the right way to number the rows using an Excel Table:
Note that in the formula above, I have used Table2, as that is the name of my Excel table. You can replace Table2 with the name of the table you have.
There are some added benefits of using an Excel Table while numbering rows in Excel:
- Since Excel Table automatically inserts the formula in the entire column, it works when you insert a new row in the Table. This means that when you insert/delete rows in an Excel Table, the row numbering would automatically update (as shown below).
- If you add more rows to the data, Excel Table would automatically expand to include this data as a part of the table. And since the formulas automatically update in the calculated columns, it would insert the row number for the newly inserted row (as shown below).
7] Adding 1 to the Previous Row Number
This is a simple method that works.
The idea is to add 1 to the previous row number (the number in the cell above). This will make sure that subsequent rows get a number that is incremented by 1.
Suppose you have a dataset as shown below:
Here are the steps to enter row numbers using this method:
- In the cell in the first row, enter 1 manually. In this case, it’s in cell A2.
- In cell A3, enter the formula, =A2+1
- Copy and paste the formula for all the cells in the column.
The above steps would enter serial numbers in all the cells in the column. In case there are any blank rows, this would still insert the row number for it.
Also note that in case you insert a new row, the row number would not update. In case you delete a row, all the cells below the deleted row would show a reference error.
These are some quick ways you can use to insert serial numbers in tabular data in Excel.
In case you are using any other method, do share it with me in the comments section.
You May Also Like the Following Excel Tutorials:
- Delete Blank Rows in Excel (with and without VBA).
- How to Insert Multiple Rows in Excel (4 Methods).
- How to Split Multiple Lines in a Cell into a Separate Cells / Columns.
- 7 Amazing Things Excel Text to Columns Can Do For You.
- Highlight EVERY Other ROW in Excel.
- How to Compare Two Columns in Excel.
- Insert New Columns in Excel
Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web 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 Excel Starter 2010 More…Less
This article describes the formula syntax and usage of the ROW function in Microsoft Excel.
Description
Returns the row number of a reference.
Syntax
ROW([reference])
The ROW function syntax has the following arguments:
-
Reference Optional. The cell or range of cells for which you want the row number.
-
If reference is omitted, it is assumed to be the reference of the cell in which the ROW function appears.
-
If reference is a range of cells, and if ROW is entered as a vertical array, ROW returns the row numbers of reference as a vertical array.
-
Reference cannot refer to multiple areas.
-
Examples
Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter. If you need to, you can adjust the column widths to see all the data.
Formula |
Description |
Result |
---|---|---|
=ROW() |
Row in which the formula appears |
2 |
=ROW(C10) |
Row of the reference |
10 |
Need more help?
Just like the COLUMN function, the ROW function in Excel is also an important cell reference function in excel.
This tutorial focuses on everything that you need to know about the ROW formula in excel. This blog covers the purpose of the ROW excel formula, its syntax, argument, and examples.
Table of Contents
- What is Use of ROW Function in Excel
- Syntax and Argument
- Examples of ROW Formula in Excel
- Using ROW Function (without argument)
- Using ROW Formula (with argument)
- Practical Usable of ROW Formula
Here we go 😎
What is Use of ROW Function in Excel
By using the excel ROW function, you can find and get the row number of the selected and active cell or any other cell reference.
The ROW excel formula returns a whole number as its result (i.e. 1, 2, 3, 4, …).
Syntax and Argument
=ROW([reference])
As seen above, the ROW formula in excel has one optional input argument viz [reference].
- [reference] – This is the optional argument in which you need to enter the reference of the cell for which you want to find the row number.
If you keep the input argument of the ROW function as blank, excel would find and return the row number of the cell in which you are entering the =ROW() formula.
Examples of ROW Formula in Excel
In this section of the blog, we would go through both the types of examples of the ROW formula – i.e. with empty parenthesis and with cell reference.
Using ROW Function (without argument)
As mentioned in the above section, the input argument of the ROW function is an optional argument. It means that if you keep the formula parenthesis as empty, excel finds and returns the row number of the cell in which the formula resides.
Try entering this formula in cell D12.
=ROW()
As a result, you would notice that excel returns the whole number 12. This is because the row number of active cell D12 is 12.
Let us now consider another example by using the formula input argument.
Using ROW Formula (with argument)
To get the row number of the cell other than the active or selected cell, simply put the cell reference inside the ROW function parenthesis.
Suppose, we want to get or return the row number of the cell $F$18 in cell A1. Use this formula-
=ROW(F18) or =ROW($F$18)
Now, when you are clear about how to use the ROW function in excel with and without input argument, let us consider some practical applicability of this formula.
Practical Usable of ROW Formula
In practical projects, I generally use this function to get and return the sequence or the serial number of the table, like this:
=ROW()-3
In the above examples, the ROW() portion of the above formula returns the row number of selected cell A4 (i.e. 4). And then 3 is deducted from the result of the ROW() portion in order to nullify the impact of blanks rows 1, 2, and 3.
RELATED POSTS
-
CELL Function in Excel – Get Information About Cell
-
ADDRESS Function in Excel – Get Excel Cell Address
-
N Function in Excel – Usage and Examples
-
ISREF Function in Excel – Checking for Cell Reference
-
COLUMNS Function in Excel – Get Number of Columns
-
OFFSET Function in Excel – Jump Rows and Columns