Divide a range of cells by same number
How to divide a range of cells by the same number using Excel and VBA methods
In this example we will be dividing all of the values in range (B3:C7) by the number captured in cell E3, which is 5. This image shows the starting point without any adjustments. |
1. Select the cell that captures the number that you want to divide the range of numbers by. 2. Copy the selected cell. Note: in this example we are dividing the range of numbers by 5, which is captured in cell E3. To copy the cell you can use the shortcut method by pressing Ctrl + C keys simultaneously. |
3. Select the range of cells that captures the numbers that you want to divide. Note: in this example we are dividing the range of numbers captured in range (B3:C7). |
4. Select the Home tab. |
5. Click on Paste in the Clipboard group. 6. Click on Paste Special. |
7.Select the All option in the Paste section. 8. Select the Divide option in the Operation section. 9. Click OK. |
This image shows the final outcome of the process explained above. All of the numbers in range (B3:C7) have been divided by 5. |
=B8/$B$5
|
The formula divides the number in cell B8 by the value in cell B5. Cell B5 has been treated as an absolute row and column, given we have applied $ signs in front of the row and column reference. This will allow you to drag the formula down to row 12 and column F without adjusting the B5 cell reference, which captures the number that we are dividing by.
|
Dim ws As Worksheet
Dim rng As Range
Dim myVal As Range
Set rng = ws.Range("B3:C7")
Next myVal
End Sub
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
Worksheet Name: Have a worksheet named Analysis.
Value Range: If using the same VBA code the range of values that you want to divide need to be captured in range ("B3:C7") in the Analysis worksheet.
Number to divide by: If using the same VBA code the number that you want to divide the range of values by needs to be captured in cell ("E3") in the Analysis worksheet.
Value Range: Select the range of values that you want to divide by changing the range reference ("B3:C7") in the VBA code to any cell in the worksheet, that doesn't conflict with formula.
Number to divide by: Select the number that want to divide the range of values by changing the value in cell ("E3") or changing the cell reference ("E3"), in the VBA code, to any cell in the worksheet that captures the number that you want to divide by and doesn't conflict with formula.
ADDITIONAL NOTES
Note 1: The VBA code returns the divided numbers in the same range where the numbers that you are dividing by are captured.
This tutorial explains and provides step by step instructions on how to divide a range of cells by the same number using Excel and VBA methods.
Excel Methods: Using Excel you can divide a range of cells by the same number using either the paste special option or a formula. Using the paste special approach the existing values that you want to divide will be replaced with the divided numbers. Using the formula approach the results will need to be presented in a different range. In this example, using the formula method, the results are captured in range E8:F12.
VBA Method: The VBA method in this tutorial shows how to automate this process. The results for this example replace the existing numbers that you are dividing. This derives with the same result as the Excel (paste special) method.
Related Topic | Description | Related Topic and Description |
---|---|---|
Add same number to a range of cells | How to add the same number to a range of cells using Excel and VBA methods | |
Subtract same number from a range of cells | How to subtract the same number from a range of cells using Excel and VBA methods | |
Multiply a range of cells by same number | How to multiply a range of cells by the same number using Excel and VBA methods |