Use VBA to enter formulas in cells in the VBA research loop

Source: Internet
Author: User

Iamlaosong

Looking at a simple loop program, after VBA reads the data from the database, you need to enter a summation formula in the last cell:

<span style= "FONT-SIZE:14PX;" >lineno = [A65536]. End (Xlup). Rowfor i = 3 to Lineno    Cells (i, 9). FORMULAR1C1 = "=rc[-3]+rc[-2]+rc[-1]" Next i</span>


The formula means cells (i, 9) = Cells (I, 6) + cells (i,7) +cells (I, 8), where rc[-3] represents the formula in the same row The first 3 columns of the cell.

How do I represent the first 3 rows in the same column? Very simple, with r[-3]c on it. And so on, the same row after three columns is rc[3], the current cell diagonal diagonally is r[-1]c[-1], the back diagonal is r[1]c[1] ...

Use VBA to enter formulas in cells in the VBA research loop

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.