Use VBA in Excel to convert dollars to renminbi
1, first we open a table as an example. The numerical units in the example are all RMB and we convert them to dollar units.
2, we press ALT + F11 combination shortcut to enter VBE edit it, insert a new module, and in the Code Editor write the following code:
Option Explicit
Sub TOUSD ()
Dim I as Integer
Dim C as Integer
For i = 6 to 17
c = Cells (i, 13). Value/6
Cells (i) = C
Next
End Sub
3, we read this code, first is the variable declaration, the establishment of the process, and then declared 2 variables I and C, where I variables used to loop, c variables to store the cell original value and calculate.
4, using for loop, the I-value loop is given to 6to17, each time the 13-column cell value is computed and written to the original corresponding cell, the formula used is the exchange rate of RMB 6:1.
5. Using this macro in the Activity list, you can see that the actual payroll has become a dollar unit, but it does not show up, and this method is not perfect, if you need to add data, you need to modify the corresponding code in the VBE.
6. We can modify the code, create a new variable s, and use the InputBox function to assign value to s, and then modify the I loop to 6tos. We can also quickly get the answer by adding the data.