Excel2007 Learn VBA notes-calculate the pore ratio of mixtures

Source: Internet
Author: User

1. How do I select all the values in a column?

Dim  as Range Set Rng=range ([C2],cells (Rows.Count,"C"). End (xlup)) for each in rng    ... Next Cell
Suba cell that iterates through a column of activity ()DimRng asRangeDimI as IntegerI=0SetRNG = Range ([A1], Cells (Rows.Count,"A"). End (xlup)) for  eachCellinchrng i= i +1NextCellMsgBoxIEnd Sub

VBA calculates the mixture porosity ratio:

1 Subcalculate the mixture porosity ratio ()2     'st_date = Sheets ("Table 1"). Range ("I2"). Value3     DimE1 as Double, E2 as Double, Theta as DoubleF as Double4Sheets ("Sheet1"). Range ("A1") ="F"5Sheets ("Sheet1"). Range ("B1") ="E1"6Sheets ("Sheet1"). Range ("C1") ="E2"7Sheets ("Sheet1"). Range ("D1") ="Theta2low"8Sheets ("Sheet1"). Range ("F1") ="F1"9Sheets ("Sheet1"). Range ("G1") ="F2"TenSheets ("Sheet1"). Range ("H1") ="f3" OneSheets ("Sheet1"). Range ("I1") ="f4" ASheets ("Sheet1"). Range ("J1") ="f5" -Sheets ("Sheet1"). Range ("K1") ="f6" -Sheets ("Sheet1"). Range ("L1") ="F7" theSheets ("Sheet1"). Range ("M1") ="F8" -Sheets ("Sheet1"). Range ("N1") ="F9" -      -     DimI as IntegerJ as Integer +     'given initial value -      fori =2  to Ten +Sheet1.cells (I,1) ="F"& I-1 A         IfI <Ten/2+1  Then atSheet1.cells (I,2) =0.2* (I-1)'E1 -Sheet1.cells (I,3) =1 'E2 -         Else -Sheet1.cells (I,2) =1 -Sheet1.cells (I,3) =1-(I-6) *0.2 -         End If inSheet1.cells (I,4) = (Cells (i,2) + Cells (i,2) * Cells (I,3)/(Cells (I,2) + Cells (i,3) +2* Cells (I,2) * Cells (I,3)) -     NextI toCells (1,5) ="Theta" 'the volume ratio of a stone +      fori =2  to 1002 -Cells (I,5) =0+0.001* (I-2) the          forj =1  to 9 *         IfCells (I,5) < Cells (J +1,4) Then $Cells (i, J +5) = Cells (j +1,2) * (1-Cells (I,5)/(Cells (I,5) * Cells (j +1,2) +1)Panax Notoginseng         Else -Cells (i, J +5) = Cells (i,5) * Cells (j +1,3) / (1+ Cells (j +1,3) * (1-Cells (I,5))) the         End If +         NextJ A     NextI the  + End Sub

Excel2007 Learn VBA notes-calculate the pore ratio of mixtures

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.