In this article, I’ll show you how you can use the **VBA** range with a variable row number in Excel. You’ll learn to work with the** VBA** range to select a range of cells, insert numbers into a range of cells, perform the mathematical operations in a range of cells, and color a range of cells, all with a variable row number.

VBA Code to Set a Range with Variable Row Number in Excel (Quick View)

`Sub Range_with_Variable_Row_Number()First_Cell = InputBox("Enter the First Cell of the Range: ")Row_Number = Str(Range(First_Cell).Row)Number_of_Rows = InputBox("Enter the Total Number of Rows of the Range: ")Set Rng = Range(First_Cell & ":" & Mid(First_Cell, 1, Len(First_Cell) - Len(Row_Number) + 1) & Mid(Str(Int(Number_of_Rows) + Int(Row_Number) - 1), 2, 10))End Sub`

**⧭**** Explanation of the Code:**

- The code takes two inputs, the first cell of the range, called
**First_Cell**, and the total number of variable rows of the range, called**Number_of_Rows**. - Then it creates a range of rows called
**Rng**, starting from the**First_Cell**up to the total number of rows you want. - For example, if your
**First_Cell**is**B4**and**Number_of_Rows**is**10**, then the output**Rng**is**B4:B13**. - Always use the
**Relative Cell Reference**of the**First_Cell**, not the**Absolute**or the**Mixed Cell Reference**(Use**B4**, not**$B$4**or**$B4**).

**Table of Contents** hide

Download Practice Workbook

4 Examples to Use VBA Range with Variable Row Number in Excel (Quick View)

1. Select a Range with Variable Row Number with VBA in Excel

2. Insert Numbers into a Range with Variable Row Number in Excel

3. Perform Mathematical Operation on a Range with Variable Row Number in Excel

4. Color Cells of a Range with Variable Row Number in Excel

Conclusion

Related Articles

**Download Practice Workbook**

**VBA Range with Variable Row Number.xlsm**

**4 Examples to Use VBA Range with Variable Row Number in Excel (Quick View)**

Here we’ve got a data set with the **Names** and **Salaries** of some employees of a company called Jupyter Group.

Today we’ll try to work with a range with a variable row number using **VBA** on this data set.

**1. Select a Range with Variable Row Number with VBA in Excel**

First of all, let’s develop a **Macro** to select a range with a variable row number using **VBA**.

Let’s select the names of the 1st **5** employees.

You can use the following **VBA code** for this purpose:

**⧭**** VBA Code:**

`Sub Select_Range()First_Cell = InputBox("Enter the First Cell to Select: ")Row_Number = Str(Range(First_Cell).Row)Number_of_Rows = InputBox("Enter the Number of Rows to Select: ")Rng = First_Cell & ":" & Mid(First_Cell, 1, Len(First_Cell) - Len(Row_Number) + 1) & Mid(Str(Int(Number_of_Rows) + Int(Row_Number) - 1), 2, 10)Range(Rng).SelectEnd Sub`

**⧭**** Output:**

Run the Macro (**Select_Range**). You’ll get two input boxes.

The **1st** box will ask you to enter the 1st cell of the range you want to select. Here it’s **B4**, the cell with the 1st employee.

Click **OK**. The 2nd Input box will ask you the number of rows you want to select. Here it’s **5**.

Again click** OK**. And you’ll get the names of the first **5** employees selected in your data set.

**Read More:** How to Get Row Number from Range with Excel VBA (9 Examples)

**2. Insert Numbers into a Range with Variable Row Number in Excel**

You can also insert numbers into a range with a variable row number with **VBA **in Excel.

You can insert both a fixed number and a series of numbers.

Let’s number the 1st **5 **employees from **1 to 5**.

That is, insert a series of **1 to 5** left to the names of the 1st **5** employees (**A4:A8**).

You can use the following **VBA code** for this purpose:

**⧭**** VBA Code:**

`Sub Insert_Numbers()First_Cell = InputBox("Enter the First Cell to Insert Number: ")Row_Number = Str(Range(First_Cell).Row)Number_of_Rows = InputBox("Enter the Total Number of Rows to Insert Numbers: ")Set Rng = Range(First_Cell & ":" & Mid(First_Cell, 1, Len(First_Cell) - Len(Row_Number) + 1) & Mid(Str(Int(Number_of_Rows) + Int(Row_Number) - 1), 2, 10))Series_or_Fixed = Int(InputBox("Enter 1 to Enter a Series of Numbers: " + vbNewLine + vbNewLine + "OR" + vbNewLine + vbNewLine + "Enter 2 to Enter a Fixed Number: "))If Series_or_Fixed = 1 ThenFirst_Number = Int(InputBox("Enter the First Number: "))Increment = Int(InputBox("Enter the Increment: "))For i = 1 To Rng.Rows.CountRng.Cells(i, 1) = First_Number + (i - 1) * IncrementNext iElseIf Series_or_Fixed = 2 ThenNumber = Int(InputBox("Enter the Fixed Number: "))For i = 1 To Rng.Rows.CountRng.Cells(i, 1) = NumberNext iEnd IfEnd Sub`

**⧭**** Output:**

Run this **Macro** (**Insert_Numbers**). You’ll get a few Input boxes.

The **1st** box will ask you to enter the first cell to insert the numbers. Here it’s **A4**.

Click **OK**. The **2nd** box will ask you to enter the total number of rows to insert numbers.

Here it’s **5**.

The **3rd** box will ask you whether you want a series of numbers or a fixed number.

Enter **1** for a series of numbers.

Enter **2** for a fixed number.

Here I want a series of numbers. So I’ve entered **1**.

The **4th** box will ask you the first number of the series. I want a series of **1 to 5**. So, I’ve entered **1**.

The final box will ask you to enter the increment. In a series of **1, 2, 3, 4, 5,** it’s **1**.

Click **OK**. And you’ll get a series of** 1 to 5** in the range **A4:A8**.

**Read More:** How to Use Range with Variable Row Number in Excel

**Similar Readings**

**VBA to Use Range Based on Column Number in Excel (4 Methods)****How to Select Range Based on Cell Value VBA (7 Ways)****Use the Range Object of VBA in Excel (5 Properties)****VBA to Set Range in Excel (7 Examples)**- How to Find Row Number Using VBA in Excel (4 Macros)

**3. Perform Mathematical Operation on a Range with Variable Row Number in Excel**

Next, we’ll develop a **Macro** to perform a mathematical operation on a range with a variable row number.

For example, let’s think for a moment that the chief of Jupyter group wants to increase the salaries of the first 5 employees by **$10,000**.

We’ll develop a **Macro** to accomplish his purpose.

You can use the following **VBA code**:

**⧭**** VBA Code:**

`Sub Mathematical_Operation()First_Cell = InputBox("Enter the First Cell to Perform Operation: ")Row_Number = Str(Range(First_Cell).Row)Number_of_Rows = InputBox("Enter the Total Number of Rows to Perform Operation: ")Set Rng = Range(First_Cell & ":" & Mid(First_Cell, 1, Len(First_Cell) - Len(Row_Number) + 1) & Mid(Str(Int(Number_of_Rows) + Int(Row_Number) - 1), 2, 10))Operation = Int(InputBox("Enter the Operation to Perform: " + vbNewLine + "Enter 1 for Addition: " + vbNewLine + "Enter 2 for Subtraction: " + vbNewLine + "Enter 3 for Multiplication: " + vbNewLine + "Enter 4 for Division: "))Operations = Array("Add", "Subtract", "Multiply", "Divide")Number = Int(InputBox("Enter the Number to " + Operations(Operation - 1) + ": "))For i = 1 To Rng.Rows.CountIf Operation = 1 ThenRng.Cells(i, 1) = Rng.Cells(i, 1).Value + NumberEnd IfIf Operation = 2 ThenRng.Cells(i, 1) = Rng.Cells(i, 1).Value - NumberEnd IfIf Operation = 3 ThenRng.Cells(i, 1) = Rng.Cells(i, 1).Value * NumberEnd IfIf Operation = 4 ThenRng.Cells(i, 1) = Rng.Cells(i, 1).Value / NumberEnd IfNext iEnd Sub`

**⧭**** Output:**

Run the **Macro** (**Mathematical_Operation**). You’ll get **4** Input boxes.

The **1st** box, as usual, will ask you to enter the first cell to perform the operation.

In this example, it’s the salary of the 1st employee, cell **C4**.

The **2nd box** will ask you the total number of rows to perform the operation.

The 3rd box will ask you to enter the operation you want to perform.

Enter **1** for addition.

Enter **2** for subtraction.

**3** for Multiplication.

And **4** for a Division.

Here I want an addition. So I have entered **1**.

Finally, the **4th** box will ask you to enter the number to add. Here I’ve entered **10000**.

Click **OK**. And you will find the salaries of the first 5 employees increased by **$10,000**.

**Read More:** Find Stringin Column and Return Row Number in Excel (7 Ways)

**4. Color Cells of a Range with Variable Row Number in Excel**

Finally, we’ll develop a **Macro** to color the cells of a range with a variable row number in Excel.

Let’s color the names of the 1st five employees red.

You can use the following **VBA code**:

**⧭**** VBA Code:**

`Sub Color_Range()First_Cell = InputBox("Enter the First Cell to Color: ")Row_Number = Str(Range(First_Cell).Row)Number_of_Rows = InputBox("Enter the Total Number of Rows to Color: ")Set Rng = Range(First_Cell & ":" & Mid(First_Cell, 1, Len(First_Cell) - Len(Row_Number) + 1) & Mid(Str(Int(Number_of_Rows) + Int(Row_Number) - 1), 2, 10))Color_Code = Int(InputBox("Enter the Color Code: " + vbNewLine + "Enter 3 for Color Red." + vbNewLine + "Enter 5 for Color Blue." + vbNewLine + "Enter 6 for Color Yellow." + vbNewLine + "Enter 10 for Color Green."))Background_or_Text = Int(InputBox("Enter 1 to Color the Whole Background of the Cells: " + vbNewLine + vbNewLine + "Or" + vbNewLine + vbNewLine + "Enter 2 to Color Only the Texts: "))For i = 1 To Rng.Rows.CountIf Background_or_Text = 1 ThenRng(i, 1).Interior.ColorIndex = Color_CodeElseIf Background_or_Text = 2 ThenRng.Cells(i, 1).Characters(1, Len(Rng.Cells(i, 1))).Font.ColorIndex = Color_CodeEnd IfNext iEnd Sub`

**⧭**** Output:**

Run the **Macro** (**Color_Range**). You’ll get 4 input boxes.

The **1st** box will ask you to enter the first cell to color.

Here it’s the first employee, cell **B4.**

The **2nd** box will ask for the total number of rows to color. Here it’s **5**.

The **3rd** box will ask you to choose the color. Enter any color index according to the **Microsoft Color Code**.

Here I’ve entered **6** (For **yellow** color).

The final box will ask whether you want to color the whole background of the cells or the only texts.

I’ve entered **1** (Whole background).

Click **OK**. And you’ll get the whole background of the 1st 5 names highlighted in yellow.

**Read More:** How to Get Row Number of Current Cell in Excel (4 Quick Ways)

**Conclusion**

Using these methods, you can use the **VBA** range with a variable row number in Excel. Do you have any questions? Feel free to ask us.

## Related Articles

**How to Use VBA Range Offset (11 Ways)****VBA for Each Cell in Range in Excel (3 Methods)****Loop through a Range for Each Cell with Excel VBA (Ultimate Guide)****Excel VBA Copy Range to Another Sheet (8 Easiest ways)**- Excel VBA: Find String in Column and Return Row Number
- How to Increment Row Number in Excel Formula (6 Handy Ways)

## FAQs

### How do you get a row number for a range in Excel VBA? ›

Get Row Number with VBA with Input Box

**Declare two variables- movie and row,** **Set our movie variable to be equal to the value in the InputBox** (the user will input this when the code executes). We set the row variable to be the cell in which the movie is found.

**How do you select a range of variables in Excel VBA? ›**

The Range variable in Excel VBA is an Object variable. Whenever we use the Object variable, we need to **use the “Set” keyword and set the object reference to the variable**. Without setting the reference, we cannot use an object variable.

**Can I use variable in range VBA? ›**

**In VBA we have a data type as a range that is used to define variables as a range that can hold a value of the range**. These variables are very useful in complex programming and automation. Often variable range is used with the set statements and range method.

**How do I insert a specific number of rows in Excel VBA? ›**

**How to insert specific number of rows**

- Sub InsertRows1() 'Define variables. Dim AnchorRow As Integer, RowCount As Integer. ...
- The next and final sample code will insert a specific number of rows above the user-prompted cell.
- 'This macro will insert static number of rows above the user-prompted cell. Sub InsertRows2()

**How do you refer to cell range in row 5? ›**

Selection using the interface: **click on cell A1, position your mouse over cell C5, press and hold <Shift> and click on cell C5**. Your range should be highlighted.

**How do I go to a specific row number? ›**

**How to go to specific row in a worksheet?**

- Go to specific row in a worksheet with Name Box.
- Go to specific row in a worksheet with Go To command.
- Type the cell address of the row which you want to jump to directly, for example, I will input the A560 into the Name Box to go the row 560, see screenshot:

**How do you select multiple variables? ›**

To select multiple variables that are not grouped together in the variable list, **click the first variable, then Ctrl-click the next variable, and so on (Macintosh: Command-click)**.

**How do you use dynamic range in VBA? ›**

**Dynamic Range**

- First, we declare one variable and two Range objects. ...
- We add the line which changes the background color of all cells to 'No Fill'. ...
- We initialize rng with the numbers. ...
- We initialize maximum with the maximum value of the numbers. ...
- Finally, we color the maximum value. ...
- Add a number.

**How do you set a range as a variable? ›**

To use a range or a single cell as a variable, first, you need to **declare that variable with the range data type.** **Once you do that you need to specify a range of a cell to that variable using the range object**. This also gives you access to all the properties and methods that you can use with a range.

**How do you set a variable to a number in VBA? ›**

In VBA, declaring variables is optional, but you can't declare AND set the variable at the same time. We've added a line that assigns the value of a variable. In VBA, just **append “.** **Value”, an equals sign, and the value you want to assign (in quotation marks)**.

### Can you set variables in VBA? ›

**You can declare several variables in one statement**. To specify a data type, you must include the data type for each variable.

**How do I insert 4 rows after every row? ›**

**Insert multiple rows in Excel using the standard menu options**

- Select the cells where the empty rows need to appear and press Shift + Space.
- When you pick the correct number of rows, right-click within the selection and choose the Insert option from the menu list. Tip.

**How do I add a specific number of rows in numbers? ›**

**Add or remove rows and columns**

- Tap the table.
- Do any of the following: Add or delete a row or column at the edge of the table: Tap. in the bottom-left corner of the table to add one row; drag. down or up to add or delete multiple rows. Tap. in the top-right corner of the table to add one column; drag.

**How do I find the row number of a specific value in Excel? ›**

In the first cell of the range that you want to number, **type =ROW(A1)**. The ROW function returns the number of the row that you reference.

**What is the cell address of 4th row? ›**

In each cell there is an address of the cell the address of cell is started from A1 the address of first row and first column . That's why the address of f 4th row and 4th column is **D4**.

**How do I return a cell value every 5 or nth row in Excel? ›**

**To copy values from every 5th row, starting with the first row in our data, we follow these steps:**

- Select cell E3.
- Enter the formula: =OFFSET($C$3,(ROW(C1)-1)*5,0)
- Press ENTER.
- Copy and paste the formula to the succeeding cells E4 and E5.
- Select cell E9.
- Enter the formula: =OFFSET($C$3,(ROW(C1)*5-1),0)
- Press ENTER.

**How do I compare 5 rows in Excel? ›**

**On the Home tab, go to Editing group, and click Find & Select > Go To Special…** **Then select Row differences and click the OK button**. The cells whose values are different from the comparison cell in each row are colored.

**How do I select a row with a specific value? ›**

**You can use one of the following methods to select rows in a pandas DataFrame based on column values:**

- Method 1: Select Rows where Column is Equal to Specific Value df. loc[df['col1'] == value]
- Method 2: Select Rows where Column Value is in List of Values. df. ...
- Method 3: Select Rows Based on Multiple Column Conditions df.

**How do I autofill to a specific row? ›**

Select the cell with the formula and the adjacent cells you want to fill. Click Home > Fill, and choose either Down, Right, Up, or Left. Keyboard shortcut: You can also press Ctrl+D to fill the formula down in a column, or **Ctrl+R to fill the formula to the right in a row**.

**How do you select nth row? ›**

**ROW_NUMBER (Window Function)**

ROW_NUMBER (Window Function) is a standard way of selecting the nth row of a table. It is supported by all the major databases like MySQL, SQL Server, Oracle, PostgreSQL, SQLite, etc.

### What are the 3 method to selecting multiple cells? ›

Select one or more cells

To select a range, **select a cell, then with the left mouse button pressed, drag over the other cells**. Or use the Shift + arrow keys to select the range. To select non-adjacent cells and cell ranges, hold Ctrl and select the cells.

**Can I assign 2 variables at once? ›**

**Multiple variable assignment is also known as tuple unpacking or iterable unpacking.** **It allows us to assign multiple variables at the same time in one single line of code**. In the example above, we assigned three string values to three variables in one shot. As the output shows, the assignment works as we expect.

**How do I combine multiple variables into one? ›**

**Method**

- Select the variables or variable set from the Data Sets tree that you want to merge. ...
- From the toolbar menu, select Combine > As Variable Set > Merge Variables.
- At the next prompt choose whether or not you want to hide the input variables.

**How do I AutoFill a range in Excel VBA? ›**

**How to Use AutoFill in VBA?**

- Range (“A1”): What are the cells to identify the pattern of the fill series.
- Destination: Till what cell do you want to continue the fill series pattern. Here, we need to mention the full range of cells.
- Type as xlAutoFillType: Here, we can select the series fill type.

**How do you solve for dynamic range? ›**

Calculating and Expressing Dynamic Range

A dynamic range is really just a ratio: you **take the maximum signal level and divide it by the minimum signal level**.

**How do I create a dynamic range macro? ›**

**Use Dynamic Ranges in Pivot Tables**

- Select a cell in the database.
- Choose Data | PivotTable and PivotChart Report.
- Select 'Microsoft Excel List or Database', click Next.
- For the range, type myData , then click Next.
- Click the Layout button.
- Drag field buttons to the row, column and data areas. ...
- Click OK, then click Finish.

**What is dynamic formula in Excel? ›**

Excel formulas that return a set of values, also known as an array, return these values to neighboring cells. This behavior is called spilling. **Formulas that can return arrays of variable size** are called dynamic array formulas.

**How do I create a dynamic dependent list in Excel? ›**

**To create a dynamic dependent drop down list in Excel, carry out these steps:**

- Get items for the main drop down list. ...
- Create the main drop down. ...
- Get items for the dependent drop down list. ...
- Make the dependent drop down. ...
- Set up the first drop down. ...
- Configure the second drop down. ...
- Set up the third drop down.

**What are the 4 rules for creating variables? ›**

**Rules of naming variables**

- Name your variables based on the terms of the subject area, so that the variable name clearly describes its purpose.
- Create variable names by deleting spaces that separate the words. ...
- Do not begin variable names with an underscore.
- Do not use variable names that consist of a single character.

**What is range set example? ›**

The Range is the difference between the lowest and highest values. Example: **In {4, 6, 9, 3, 7} the lowest value is 3, and the highest is 9.** **So the range is 9 − 3 = 6**. It is that simple!

### What is range () give an example to explain it? ›

It **creates the sequence of numbers from start to stop -1** . For example, range(5) will produce [0, 1, 2, 3, 4] . The result contains numbers from 0 to up to 5 but not five.

**How do you set a variable to a number? ›**

The first time a variable is assigned a value, it is said to be initialised. The = symbol is known as the assignment operator. It is also possible to **declare a variable and assign it a value in the same line**, so instead of int i and then i = 9 you can write int i = 9 all in one go.

**How do you assign a number to a variable in Excel? ›**

**Inserting variable formulas**

- Open the workpaper with Microsoft Excel.
- Select the cell in which to insert a variable.
- In Microsoft Excel, choose Insert Formula. ...
- In the Variable Type section, choose Amount or Text.

**How do you show the value of a variable in VBA? ›**

In the VBA editor **go to the View menu and click on Locals Window.** **Each time F8 is pressed one line of VBA is executed.** **When the range MyRange is set, you can see that values appear for it in the Locals window**. By examining the MyRange object you can drill down to see the values in it.

**What are the types of variables in VBA? ›**

**Variable Data Types**

- Integer: Used to store number values that won't take on decimal form.
- Single: Used to store number values that may take on decimal form. ...
- Double: A longer form of the single variable. ...
- Date: Stores date values.
- String: Stores text. ...
- Boolean: Used to store binary results (True/False, 1/0)

**How many types of variables are there in VBA? ›**

Data Type | Stored | Range of Values |
---|---|---|

Byte | 1 Byte | 0 to 255 |

Integer | 2 Bytes | -32,768 to 32,767 |

Single | 4 Bytes | -3.402823E38 to -1.401298E-45 for negative values, 1.401298E-45 to 3.402823E38 for positive values |

Long | 4 Bytes | -2,147,483,648 to 2,147,483,648 |

**Can variables start with a number in VBA? ›**

As of Microsoft Excel 2010, VBA variable names are subject to the following restrictions: They must begin with a letter. **Numbers and underscores can be used later in the name**.

**How do you insert 4 rows at a time? ›**

Select the cell, or the range of cells, to the right or above where you want to insert additional cells. Tip: Select the same number of cells as you want to insert. For example, to insert five blank cells, select five cells. **Hold down CONTROL, click the selected cells, then on the pop-up menu, click Insert**.

**How do I group every 4 rows in Excel? ›**

**On the Data tab, in the Outline group, click the Group button, select Rows, and click OK**. This will add a bar on the left side of the worksheet that spans the selected rows: In a similar manner, you create as many outer groups as necessary.

**Which formula is used to add a number of rows? ›**

**=SUM(LEFT)** adds the numbers in the row to the left of the cell you're in. =SUM(BELOW) adds the numbers in the column below the cell you're in. =SUM(RIGHT) adds the numbers in the row to the right of the cell you're in.

### How do I extract a row number in Excel VBA? ›

**How To Get Row Number By A Single Click Using VBA In Microsoft Excel 2010**

- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- Dim rownumber As Integer.
- rownumber = ActiveCell.Row.
- If ActiveCell.Value <> "" Then.
- MsgBox "You have clicked on row number " & rownumber.
- End If.

**How do I find the row number in Excel VBA? ›**

To return a row number of an active cell we can **apply an ActiveCell.** **Row function in VBA**. In this example we are returning the row number into cell A1 in a worksheet named Analysis. Therefore, when the VBA code is run it will return the row number in the specific location.

**How do you reference specific rows in Excel? ›**

**How to cross reference in Excel**

- Start typing a formula in a cell.
- Click the sheet tab you want to cross-reference and select the cell or range of cells.
- Finish typing your formula and press Enter.

**How do I reference a row in Excel VBA? ›**

If the Excel VBA Range object you want to refer to is a single cell, the syntax is simply “**Range(“Cell”)**”. For example, if you want to make reference to a single cell, such as A1, type “Range(“A1″)”.

**How do I get the row number in Excel based on cell value? ›**

**The ROW function returns the row number for a cell or range**. For example, =ROW(C3) returns 3, since C3 is the third row in the spreadsheet. When no reference is provided, ROW returns the row number of the cell which contains the formula.

**How do you reference multiple rows in Excel? ›**

Click the tab for the first worksheet that you want to reference. Hold down the Shift key then click the tab for the last worksheet that you want to reference. Select the cell or range of cells that you want to reference. Complete the formula, and then press Enter.

**How do you reference a specific row in a table? ›**

The @ symbol inside a table means "this row". You can **combine this with a column name to reference a particular cell in the current row**. To reference the Total row, use the #Totals specifier. To reference a specific total, use a double set of brackets, and the column name, just like the headers row.

**How do I create a dynamic cell reference in Excel VBA? ›**

...

- Excel Dynamic Named Range [4 Ways]
- Create Dynamic Named Range with VBA in Excel (Step-by-Step Guideline)
- Data Validation Drop Down List with Excel Table Dynamic Range.
- Create a Dynamic Chart Range in Excel (2 Methods)

**How do you reference a cell by row and column number? ›**

To refer to a cell, **type the column letter followed by the row number**. For example, D50 refers to the cell at the intersection of column D and row 50.

**Can you use VLOOKUP for a row? ›**

**VLOOKUP could only search for a value in the first leftmost column of a data range**. Similarly, HLOOKUP could only search for a value in the top row of the range: When the key field is to the right of the range you want to retrieve, VLOOKUP will not work.

### What is row range with example? ›

The ROWS function returns the count of rows in a given reference as a number. For example, **=ROWS(A1:A5) returns 5, since the range A1:A5 contains 5 rows**. ROWS takes just one argument, called array, which can be a range or array.