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