## 15. Four arithmetic operations and annotations (comments)

*Some of this topic was processed by machine translation. Original*

Excel is a spreadsheet software, so if you can't calculate it, it won't be a story.

This is the same as the worksheet operator.

### Arithmetic operators

Operator | Description |

+ |
Addition |

- |
Subtraction |

* |
Multiplication |

/ |
Division |

\ | Quotient of division |

Mod |
remainder of division |

^ |
Power |

If used normally, there will be no problem.

Please be sure to enclose with () and specify the calculation order.

Stop writing statements that rely on operator precedence as it is difficult to understand.

Therefore, we will not explain the priority order.

A1 cell has a unit price of 300

In B1 cell, the quantity is 5

This is a case where 1500 is put in C1 cell as the amount of money.

Sub practice1()

Cells(1, 3).Value = Cells(1, 1).Value * Cells(1,
2).Value

End Sub

The problem is that even if you look at this macro, it is not clear what calculation is being performed.

C1 cell = A1 cell * B1 cell

I understand this, but it's unclear what it means.

### Comment

Sub practice1()

'Amount = Unit price * Quantity

Cells(1, 3).Value = Cells(1, 1).Value * Cells(1, 2).Value

End Sub

It has no effect on execution.

Sub practice1()

Cells(1, 3).Value = Cells(1, 1).Value * Cells(1, 2).Value 'Amount = Unit price * Quantity

End Sub

**'**(Single quotation) is the only comment after,

Until then, you can write macros normally.

I write comments for only one line behind

Comments on several lines are basically written from the beginning,

These are each person, and adapt to your organization's coding rules, if any.

'***************************************************************

'* Practice four arithmetic operations

'***************************************************************

Sub practice1()

Cells(1, 3).Value = Cells(1, 1).Value * Cells(1, 2).Value 'Amount = Unit
price * Quantity

End Sub

Since it is a comment, there is no particular rule on how to write it.

To make it easier to see when you see it later,

Write it so that it is easy to understand when you show it to others.

### Articles with the same theme "VBA basics"

12. Variables and data types (Dim)

13. Constants and type declaration characters (Const)

14. Character concatenation and continuation line

15. Four arithmetic operations and annotations (comments)

16. Iterative processing (For Next)

17. Iterative processing (Do Loop)

18. Get last row (End, Rows.Count)

19. General practice question 1

20. Conditional branch (If)

21. Conditional branch (ElseIf)

22. Conditional branch (Select Case)

**If you find this site useful, please share and bookmark.**

I'm going to pay close attention to the description,

If you have any mistakes or suggestions,「Contact Us」I hope you will let me know.

Use the posted VBA code at your own risk.

We are not liable for any damages such as data corruption.