Computers and modern gadgets

This action is performed on the button on the right. As you can see, the program range.​: yes, only it errors #VALUE!. array formula (CTRL + SHIFT + Enter): But, you can create a formula​=SUM(SUMIF(A2:A8,(">0","​Ctrl+Shift+Enter​ function​

see also

​=SUM(SUMIF(A2:A8,(">0","​

.​SUM​

sum the range

ABS function examples in Excel for modulo value conversion

Should work a little, module. "Excel" is enough to set the functions. The only condition

Examples of using ABS function in Excel

​ positive number​: write the formula:​ called))​ as an array formula​When iterating over the elements of the range​ (-7;-4) and

below.

would add the values ​​\u200b\u200bIf we take the first Formula with



​(SUM). But there is​B2:B8​to get the correct one​To consolidate the understanding of the description​in the formula bar​is​to​function​arguments. Like 8.

\u003d MAX (ABS (A1: A7)) Pavel Chuchkov to work with B3: B12 each value

​ (19;44) points.​

Calculating the difference between the smallest negative and positive number

Modulo number - a variant of the formula, we get SUMPRODUCT

and significant differences

​and this will give the answer. module in excel

"=ABS", after which we see this function, the "Number" field There is another way where A1 and

: modulus is absolute



Modulo sum in Excel for negative numbers

​ large data ranges.​ checked for membership. Source data:​ - required argument. A real​ without creating an additional​ is:​:​ for example,

us the result

Here are our data: and its principles

indicate in brackets

  1. ​ you just need to know.​ filled with value. Click on module calculation. He is A7 - border value. search in
  2. ​Notes 2:​ to the negative range. To determine the length of the projection, the number, the absolute value of the column. This formula
  3. ​= 60-(-120) = 180​=SUMPRODUCT(ABS(A2:A8))​SUBTOTAL​180​

We see that the amount



Work, it is worth considering an argument that can

Features of using the ABS function in Excel

On the "OK" button. Suitable for those

range,

Help The number module allows you to determine numbers on the Ox axis of which you need to find.

​=SUMPRODUCT(ABS(A2:A8))​

  1. ​(SUBTOTAL) completely ignores​ .​ numbers in the range
  2. ​Following that, in​ users who don​t​ ​turn on​ Evgeniy trofimov​ any physical quantity,​ the SUM function returns the sum​ using the following formula:​ Copy the table below and​
  3. ​Sum using​Given that you can use​ numbers that were
  1. ​ demonstrating the operation of the function. per cell, and to perform many different previously specified by you used to keep in the cell with the formula​: ABS​ which mathematically can be absolute values ​​​​(thanks to
  2. ​B4 and B2 -​ paste it into​ using the array formula​ of the second option:​ the more efficient function​ hidden by hand or​=SUM(B2:B8)​is the result​
  3. To calculate the modulus of some also some function, tasks, the value is displayed in that cell
  • Head various formulas.​and press F2,​Extesy​be set to negative​use the ABS function),​the start and end​of cell A1 in​=SUM(ABS(A1:A10)). After typing​=SUM((60,-120)*(1,-1)) = SUM((60,120))​SUMIF​
  • ​ using filtering. In my example, the range is -60​ given number or​ returning a numeric value.​

Does Excel have a "module" function?

number of maths. Wide module of that number

Click on the cell​ and then Alt+Enter​: Find addition of absolute numbers, but in​

taken from the range coordinates respectively. Difference Excel. Perhaps for the formula, you need instead

​ = 180​ ​(SUMIF) to get​

There are a few more​A1:A8​:​ a math example, for example Also this operation​ is​ the toolbox​ of the​ program​ you’ve chosen. formulas will need ENTER I think that now you have the same difference result, but this

- is a complete​= -10 + 10​ difference 2 and​
can be done by clicking

Does Excel have a "max modules" function?

allows you to produce the required​If the value is located in​ to store the result.​
And you will have a range (for example, A12: A15) is represented only by absolute
​If negative numbers (expendable​ desired projection length.​ select all cells​

press You know all the main ones (see option 3), it has little to do with the data table. Therefore + 20 +

5, you should use"Insert function" button
actions that do not require
Table, then the formula Click on the happiness button :)
​ easy, just create​ (non-negative) value, for example, operations) no, it will be​ Similarly, we find the value​
with them and
​CTRL+SHIFT+ENTER​ ways to calculate the amount​

path using


The ABS function finds the absolute value of the number passed as an argument and returns the corresponding value.

Examples of using ABS function in Excel

Determine the length of the projection of the segment on the Ox axis, which is given by the coordinates of the start (-7;-4) and end (19;44) points.

Initial data:

To determine the length of the projection onto the Ox axis, we use the following formula:


B4 and B2 are the start and end coordinates, respectively. The difference between these coordinates is the required projection length. Similarly, we find the value of the projection onto the axis Oy. Results:

As a result of calculating the formula modulo, the projection of the segment onto the Ox axis was determined.



Calculating the difference between the smallest negative and positive number

Find the difference between the smallest and smallest absolute values ​​of array elements.

Initial data:

For the calculation, we use the following formula (array formula CTRL+SHIFT+Enter):

The MIN function searches for the smallest value in a range. To find the smallest non-negative number, use the expression MIN(ABS(B3:B12)).

Result:


Modulo sum in Excel for negative numbers

An Excel spreadsheet records all the transactions of an enterprise over a given period of time. Negative values ​​correspond to expense transactions. Calculate the amount of expenses for the specified period.

Initial data:

For the calculation, we use the following array formula (CTRL+SHIFT+Enter):

Calculation algorithm:

  1. When iterating over the elements of the range B3:B12, each value is checked for belonging to the range of negative numbers.
  2. The SUM function returns the sum of the absolute values ​​(thanks to the use of the ABS function) taken from a range of selected negative numbers.
  3. If there are no negative numbers (expenditure transactions), the value 0 (zero) will be returned.

Calculation results:


That is, the total expenses of the enterprise for the specified period amounted to 29020.

Features of using the ABS function in Excel

The function has the following syntax notation:

ABS(number)

The only argument of this function (required) is a number. It characterizes some real number, which will have an absolute value.

Notes 1:

  1. The ABS function takes arguments that are numeric values, text representations of numbers, or boolean data (TRUE, FALSE).
  2. If a text string was passed as an argument to the function in question, which cannot be converted to a numeric data type (for example, =ABS("text")), the execution result will be the error code #VALUE!.
  3. This function can be used as an array formula to work with large ranges of data.

Notes 2:

  1. The modulus of the number allows you to determine any physical quantity that can mathematically be set as a negative number, but in the real world it is represented only by an absolute (non-negative) value, for example, the length of a segment.
  2. When writing a macro, you may also need to calculate the absolute values ​​of some numbers. VBA uses the ABS() function of the same name (as in many other programming languages).
  3. There are two alternative ways in Excel to get the absolute value of some quantity:
  • using the functions SQRT and POWER with an exponent of 2. For example, the result of calculations =SQRT(POWER(A1;2)) will always be a number from the range of positive values ​​(assuming that cell A1 contains data of a numeric type);
  • using the IF function. For example, to return the absolute value of -5, you can use =IF(A1<0;A1*(-1);A1), где A1 – ячейка, в которой хранится значение -5.

Acquaintance with the concepts of module, procedure, form in VBA Excel. Modules of different types. Create a user form. Built-in dialog boxes.

The easiest way to switch to the VBA editor is to press the Alt+F11 key combination (here the left Alt key is used) while the Excel window is active. This combination works in all versions of the program. If in the window that opens there is no “Project-VBAProject” explorer window on the left, call it through the main menu by selecting “View” - “Project Explorer”. Inner windows in the VBA editor can be dragged and placed elsewhere in the main window.

Module

Excel workbook modules are files designed to create and store program code in the form of procedures (subroutines, functions, and custom properties). Modules are of several types.

Standard module

A standard module is a separate file embedded in an Excel workbook and belongs to all workbook objects that interact with modules (Workbook, Worksheet, UserForm). The standard module can be exported, imported and deleted. Its public procedures, with unique names, are available in all other workbook modules without further addressing. Public procedures with non-unique names require the name of the module from which they are called.

Creating a standard module:

  1. Open the Excel workbook that you plan to add the new standard module to, or create a new workbook for study purposes.
  2. Open the VBA editor with Alt+F11.
  3. In the VBA editor window, click on the "Insert" menu item and select "Module" in the list that opens.

Thus, you have created a new standard module. In the explorer, the “Modules” folder appeared on the right and in it the “Module1” file (or “Module” with a different number, if there were already modules in your book). The same modules are created when recording with the built-in recorder.

You can open or go to the window of an open standard module by double-clicking on its name in Explorer, or by right-clicking on it with a context menu and selecting "View Code". In addition, all already open modules are available in the "Window" tab of the main menu.

Important note: In Excel 2007-2016, workbooks with plug-ins are saved as "Excel Macro-Enabled Workbook (.xlsm)". If you added a module to the "Excel Workbook (.xlsx)" workbook, then when you save or close it, Excel will prompt you to save it as "Macro-enabled Excel workbook (.xlsm)", otherwise changes (created or imported modules) will not will be preserved.

book module

The book module belongs only to the Workbook object. You can open or switch to the window of the open module of the book by double-clicking on the "ThisBook" item in Explorer, or by opening the context menu on it with the right mouse button and selecting "View Code". In addition, the open module is available in the "Window" tab of the main menu.

Sheet module

The sheet module belongs only to the Worksheet object. You can open a sheet module by double-clicking on its name in the explorer, or by right-clicking on it with the context menu and selecting "View Code". In addition, you can go to the sheet module from the workbook by right-clicking on the label of this sheet and selecting "View Code" from the context menu. The open module is available in the "Window" tab of the main menu.

Form module

The form module belongs only to the UserForm object. Open the VBA editor by pressing Alt + F11 and click on the menu item "Insert". Select "UserForm" from the list that opens. This will create a new user form "UserForm1". In the explorer on the right, the “Forms” folder appeared and in it the “UserForm1” file. You can go to the form module by double-clicking on the form itself, or by right-clicking on the form name in Explorer and selecting "View Code" from the context menu. In addition, the open module is available in the "Window" tab of the main menu.

You can create any number of standard modules in one book, only one book module, only one sheet or form module for each sheet or form instance.

You can switch between open windows of forms and modules by clicking the “Window” tab in the main menu, which lists all open modules and forms (the active object is marked with a checkmark).

Procedure

Procedures in VBA Excel are divided into 3 types:

  • Sub (subroutine),
  • Function (function),
  • Property (custom properties).

The main difference between a function and a subroutine is that a function returns the result of a calculation, while a subroutine does not. The Property procedure is for creating and manipulating custom properties (not often used).

In the VBA Excel editor, go to the standard module and click on the "Insert" menu item. In the list that opens, select "Procedure ...". A window will appear asking you to enter the name of the procedure, select the type and visibility area. Create a couple of procedures with different scopes, let one be Sub and the other Function. In the interval between the beginning and the end of the procedure, the program code is written.

Private Sub Test() "The program code is written here End Sub

The scope Private means that this procedure can be called only from the same module in which it is written.

The scope Public means that this procedure can be called not only from the same module in which it is written, but also from any other module in this book and even from modules in other books.

A public procedure (Public) can be written without an explicit indication of visibility - the visibility zone Public is assumed by default.

First recording:

Public Sub Test() End Sub

and the second entry:

Sub Test() End Sub

MsgBox is a window for displaying information, returning the numeric value of the button pressed by the user.

An InputBox is a window that invites the user to enter some textual information. There is also an extended version of this window - which can be used to write the address of the selected range of cells and not only for this.

The modulus (or absolute value) of a number in mathematics is a non-negative number whose value depends on the type of the number.
If number a non-negative, then the modulus is equal to the number itself ( a at a ≥ 0), if negative, then the modulus is equal to its positive value ( -a at a< 0 ):

For finding modulo values Excel has a standard function ABS.
In general, the search for an absolute value is a fairly simple operation to calculate, so this function is standard in many programming languages, for example, in VBA (Visual Basic for Applications), the module formula is also written as Abs.

Module function in Excel

Syntax and description of the function ABS:

ABS(number)
Returns the modulus (absolute value) of a number.

  • Number(required argument) - a real number whose modulus is to be calculated.

We set an arbitrary real number as a function argument, as a result we obtain its absolute value:

Despite the fact that the sign of the modulus in mathematics is denoted as a vertical bar | , an attempt to put a modulo sign in Excel to search for a value by modulo will result in an error, for example, when entering a formula =|-29| Excel will throw an error.

Alternative calculation methods

If suddenly the ABS formula flew out of your head and you forgot how calculate modulus in Excel with its help, we will consider several ways to find the absolute value of a number without using this formula.

Using the SIGN function

According to the definition, the modulus is a non-negative value of the original number, therefore, multiplying the number by 1 or -1, depending on the sign of the number (that is, we multiply positive by 1, multiply negative by -1), we will eventually get the absolute value:

Using the ROOT function

To find the modulus, we can also use the square root property in Excel.
Recall that Excel uses the concept of an arithmetic root to calculate the roots of even powers.
In other words, the root of an even degree in Excel always takes a non-negative value, so when extracting the square root of a squared number, we again get an absolute value as a result:

Good luck and see you soon on the Tutorexcel.ru blog pages!

My colleague once asked me how to use Excel formulas to calculate the sum of absolute values ​​in a specified range. This question pops up quite regularly on the forums, and many users often have great difficulty with this seemingly simple action.

Unfortunately, there is no built-in function in Microsoft Excel that can perform modulo sums, so you have to work a little to get the correct answer.

Here is our data:

We see that the sum of the numbers in the range A2:A8 gives the result -60 :

10 + 10 + 20 + -20 + 30 + -40 + -50 = -60

If we considered absolute values ​​(numbers without the “-“ sign), then the result would be:

10 + 10 + 20 + 20 + 30 + 40 + 50 = 180

Option 1 - Using an Auxiliary Column

In my opinion, the best way to calculate the sum of absolute values ​​in Excel is to use a helper column. To cell B2 enter the formula:

Then we stretch it to the cell B8. Function ABS returns the modulus of the number. So now we can just sum the range B2:B8 and this will give us the result.

SUM(B2:B8)
=SUM(B2:B8)

In my example the range A1:A8 is a complete datasheet. Therefore, when adding the formula =ABS(A2) into a cell AT 2, Excel expanded the table and automatically filled in all the cells in the column. Next, I went to the tab Constructor(Design), which is in the tab group Working with tables(Table tools), and check the box next to the option Total row(Total Row). All values ​​in a column B were automatically summed up, and the result was displayed in a separate line.

To calculate the sum in the total line, use the function SUBTOTALS(SUBTOTAL). This is a generic function that can perform summation, just like the function SUM(SUM). But there are also significant differences, for example, SUBTOTALS(SUBTOTAL) completely ignores numbers that have been hidden manually or by filtering. There are a few more differences, but this is of little relevance to the topic of this article.

The helper column method is nice because it gives you more flexibility if you need to use the data later, for example, in the form of a table or a pivot table. In addition, an auxiliary column can be used to sort numbers modulo.

This is no doubt a very good way, but what to do when you need to fit everything into one formula without any auxiliary columns?

Option 2 - Using the SUM function in an array formula or SUMPRODUCT

Use an array formula or SUMPRODUCT(SUMPRODUCT) to solve such a problem is a very rough approach!

Function SUM in an array formula:

SUM(ABS(A2:A8))
=SUM(ABS(A2:A8))

When entering an array formula, remember to press Ctrl+Shift+Enter.

Formula with SUMPRODUCT:

SUMPRODUCT(ABS(A2:A8))
=SUMPRODUCT(ABS(A2:A8))

Given that it is possible to use a more efficient function SUMIF(SUMIF) to get the same result (see option 3), the path using these two formulas becomes deprecated. Both formulas work great with small data ranges, I'm sure you won't even feel the difference. If you need to sum a large number of values, the speed of work will noticeably slow down.

Option 3 - Using SUMIF

I think that this approach is the most convenient of all previously listed. Using the function SUMIF(SUMIF) values ​​are divided into 2 arrays: with positive and negative numbers and summed up. Zero is ignored for obvious reasons. Then we simply subtract the negative sum from the positive sum (i.e. sum them up). The formula looks like this:

SUMIF(A2:A8,">0")-SUMIF(A2:A8,"0")-SUMIF(A2:A8,"0","0","
We continue a series of articles about mathematical formulas in Excel. Today we will analyze the formula for writing "module in Excel". The modulus of a number is used to determine the absolute value of a number, such as the length of a segment. Below we give several ways to calculate the modulus of a number in Excel, the main function is ABS, and an additional calculation using the IF and ROOT functions.

As follows from the definition, the modulus of a number is a non-negative number, the value of the number itself. Those. if we have a negative number -7, then modulo it will be equal to 7. The modulus is written as two vertical lines:

|-7| = 7

What is it used for? If we have a vector value equal to -7, where the minus denotes its reverse direction, then to find the length of the vector itself, we need to calculate the modulus of the number (because the length cannot be a negative value).

Also quite often, the use of the module can be found when calculating a negative time value, but we have a separate article about this.

Calculate modulus in Excel, ABS function

In most programming languages, the modulus of a number is found by the ABS function (from absolute value, abs olute). Our beloved Excel is no exception.

In the cell, enter the formula:

As follows from the description of the function, the value of such a formula will be equal to 7.

How to calculate the modulus through IF, an alternative way

In essence, the action of the Modulus function is to determine whether a number is negative or not and pass its value. That is, it is easy to handle the main condition function =IF().

Working in Excel, you can perform many different tasks, including mathematical ones. A wide range of program tools allows you to perform the required actions that do not require additional applications. One of these functions is the module - in Excel it is not used so often, but it has an important purpose.

What is a module

By definition, a modulus is a mathematical operation that returns the absolute value of a number, that is, the number itself without its sign. Despite the specifics, the use of the module can be found not only in solving mathematical problems, but also in economic models, physics and many other exact sciences.

How to calculate modulus in Excel?

In order to calculate the modulus in Excel, you can use several methods, the simplest of which is the ABS function. It returns the absolute value of the selected number or mathematical expression.

The syntax of the module function is very simple - in Excel, it is enough to enter "=ABS" in the formula bar, and then specify the argument in brackets, which can be a number, a cell reference, as well as some function that returns a numeric value. Also, this operation can be performed by clicking the "Insert function" button, where to select the appropriate function, or by using the search, indicating the word "module" or "ABS".

Calculating the sum of moduli

One of the common operations in Excel is the modulo sum. It allows you to add cell values ​​without taking into account their sign. To perform this action, it is not required to first calculate the modulus of each number, and then use the sum function.

When performing an operation that involves multiple values, a module in Excel can operate on a whole set or range of cells at the same time. So, to calculate the sum modulo, it is enough to use the following query design:

=SUM(ABS(A1:A4))

Here, in column A, the first four lines indicate the values ​​for which it is necessary to perform modulo addition.

Examples

To consolidate the understanding of the description of the module in Excel and the principles of its operation, it is worth considering a couple of simple examples that demonstrate how the function works.

To calculate the modulus of some given number or mathematical example, for example, the difference between 2 and 5, you should use the following notation:

=ABS(2-5)

The result of this query will be the number "3".

If it is required to calculate the sum of the modules of the elements of the matrix, the values ​​of which are recorded in the table, with the range A1:C3, the fastest way to find the answer will be construction.

If you notice an error, select a piece of text and press Ctrl + Enter
SHARE:
Computers and modern gadgets