How does Excel convert a dollar in a table to renminbi?

Source: Internet
Author: User
Tags integer

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.