Help me write out this VBA code as well as the extra credit and the challenge ex
ID: 3866280 • Letter: H
Question
Help me write out this VBA code as well as the extra credit and the challenge extra credit question.
Excel VBA assignment using Loops and IF statements Background: Engineering data must sometimes be extracted from tables using linear interpolation. That math of linear interpolation is based on the idea of similar triangles, or the point-slope formula for a line. The table defines two points (x1, y1) and (x2, y2) where the values of x1 and x2 bracket the known input value, x. In other words, x is between x1 and x2. Then linear interpolation is used to ind y: can choose which column from the spreadsheet represents the y values (3)The Sub should count the number of values in the table for use in a for-next loop. It can do this by determining the row number at the bottom of the table similar to a book example from earlier in the course (4) Sub will check to make sure the input value is between the first and last data value in the first column. If the input value is not valid, sub will display a warning message and put asterisks in the output cell y=y1 + x2-x1 (5) Sub uses data from column one (temperature) to find values Assignment from another column using linear interpolation (1)Use the provided steam data in the file (6)Your sub probably will need an If statement when checking to saturatedSteamDataT.xlsx. Copy that data into your own spreadsheet and save with the xlsm extension see if the input value is between the minimum and maximum values (2)In a separate worksheet than the one that contains the data, (7)Your sub probably will need a For Next loop to search the data to find the two temperatures that are just above and just below the input temperature identify two cells. One cell is for temperature as an input value and the other is for an output value. Select any one of the other columns to represent the output value. In the formula above, temperature represents the x values and you (8) Extra credit: Make it so the program outputs all of the thermodynamics properties corresponding to the input temperature, not just oneExplanation / Answer
ANSWER::
Fugacity + derivatives (vs. p,t,w)
Enthalpy + derivatives (vs. p,t,w)
Entropy + derivatives (vs. p,t,w)
Volume + derivatives (vs. p,t,w)
with VBA you need to create a space (remember first element is 0 as in C)
define space
Dim w(0 To 10) As Double
Dim dVw(0 To 10) As Double
' initialize process
process = 1
res = DPinit(process,stream)
' define composition
w(0) = 0.81
w(1) = 0.09
w(2) = 0.06
w(3) = 0.02
w(4) = 0.01
w(5) = 0.004
w(6) = 0.006
w(7) = 0.0
w(8) = 0.0
w(9) = 0.0
t = 280
p = 250000
' calculate volume and dV/dt dV/dp dV/dw
res = StrVvd(process,1,t,p,w(0),V,dVt,dVp,dVw(0))
in a similar way you can calculate the fugacity, enthalpy and entropy.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.