# Calculating the void ratio of a certain confining pressure by the linear difference of VBA

Source: Internet
Author: User

`1 SubChazhi ()2 'thisworkbook.worksheets ("Solvee"). Active3 DimPtotalrows as Integer, Startrows as Integer4 DimP, E, PX, ex () as Double, Gs, Pxtotalrows as Integer5Startrows =4 'row label for data start6Ptotalrows = Range ("A3"). End (Xldown). Row'data P column non-empty total rows7Pxtotalrows = Range ("C3"). End (Xldown). Row'' data px column non-empty total number of rows8 ReDimEx1  toPxtotalrows-startrows +1)'redefine the required array size for e9p = Range (Cells (Startrows,1), Cells (Ptotalrows,1))'to read P-values in Excel into an arrayTenE = Range (Cells (Startrows,2), Cells (Ptotalrows,2)) Onepx = Range (Cells (Startrows,3), Cells (Pxtotalrows,3)) A 'p = Range ("a3:a" & Totalrows) - 'e = Range ("b3:b" & Totalrows) -  the  fori =1  toPxtotalrows-startrows +1 'traversing PX -  forj =1  toPtotalrows-startrows'Traverse P -   IfP (J,1) < PX (I,1) andP (j +1,1) > px (i,1) Then 'observe where PX is in the middle of two p, then use these two p and corresponding e-linear interpolation -EX (i) = ((PX (i,1)-P (J,1))/(p (j +1,1)-P (J,1))) * (E (j +1,1)-E (J,1)) + E (J,1) +j = ptotalrows-startrows +1 'After interpolation, the next px corresponding ex -   End If +   NextJ A NextI atRange (Cells (Startrows,4), Cells (Pxtotalrows,4)) =Application.transpose (ex) - End Sub`

Calculating the void ratio of a certain confining pressure by the linear difference of VBA

Related Keywords:

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.