Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help with the conditions for determining between superheated, subcooled and

ID: 3833620 • Letter: N

Question

Need help with the conditions for determining between superheated, subcooled and saturated phase for the property table of water. I have added what i have so far in the VBA code but I cannot figure out how to write the code correctly for the If statements for the phases. Also I have added the excel table values.

Option Explicit

Private Sub CommandButton1_Click()

Dim Value1, volume, Value2, AbsT, TempaskMPa, MPa, Tempask1, pressask1, AbsF, Abss, Temppre1 As Double

Dim c, x, y, z As Integer

Dim tempask1_cell, pressask1_cell, superheat1_cell As Range

y = 0 'need for later when identifying the y value for phase'

Tempask1 = InputBox("Enter Temperature from Tables") 'asks the user to input a temperature value in celsuis to look for in the table'

Range("D3").Value = Tempask1 'sets whatever value was entered to cell d3 in the excel'

pressask1 = InputBox("Enter Pressure from Tables in kpa") 'asks user to enter pressure in kpa'

Range("E3").Value = pressask1 ' sets value of kpa to cell e3'

Set tempask1_cell = Range("B21:B96").Find(Tempask1, LookIn:=xlValues, MatchCase:=True) 'this is the range of cells set for it to look for the value inputed for temperature'

If tempask1_cell Is Nothing Then

Set tempask1_cell = Range("Q21:Q96").Find(Tempask1, LookIn:=xlValues, MatchCase:=True) 'if it doesnt find the value in the first range then it looks for it in the other table that is set'

z = 1

Else

z = 2

End If

Set pressask1_cell = Range("C21:C96").Find(pressask1, LookIn:=xlValues, MatchCase:=True) 'this is the range of cells set for it to look for the value inputed for pressure'

If pressask1_cell Is Nothing Then

Set pressask1_cell = Range("P21:P96").Find(pressask1, LookIn:=xlValues, MatchCase:=True) 'if it doesnt find the value in the first range then it looks for it in the other table that is set'

Temppre1 = pressask1_cell.Offset(0, 1).Value

Else

Temppre1 = pressask1_cell.Offset(0, -1).Value

End If

Value1 = pressask1_cell.Offset(0, -1).Value

MsgBox Value1

Value2 = Tempask1 - Value1

MsgBox Value2

If Value2 <= 0 Then

y = 1 ' if its subcooled'

volume = tempask1_cell.Offset(0, z).Value

ElseIf Value2 < 0 And pressask1 > Tempask1 Then

y = 2 'if its superheated it sets y =2'

volume = tempask1_cell.Offset(0, z).Value

ElseIf Value2 <= 0 And Tempask1 < pressask1 Then

volume = tempask1_cell.Offset(0, z).Value

y = 3 'if its saturated then it sets y to 3'

Else

y = 0

End If

If y = 3 Then 'if y was found to equal to 3 then the program will follow this if statement, if not then it moves on to the next'

MsgBox "The Temperature in Celcius is " & tempask1_cell.Value & " The Pressure in kpa is: " & pressask1 & "The Volume is: " & volume

MsgBox " Saturated Phase"

Range("D11").Value = "Saturated"

End If

If y = 0 Then

MsgBox "Error in input, enter values only from tables"

End If

If y = 1 Then

MsgBox " The temperature is " & tempask1_cell.Value & "The Pressure is: " & pressask1 & "The Volume is: " & volume

MsgBox "Subcooled phase"

Range("D11").Value = "Subcooled"

End If

If y = 2 Then 'DOES NOT WORK YET'

MPa = pressask1 / 1000

Set superheat1_cell = Range("B99:P99, B119:P119, B137:P137, B154:P154, B171:P171, B188:P188, B204:P204, B220:P220, B235:P235, B249:P249, B263:P263").Find(MPa, LookIn:=xlValues, MatchCase:=True)

c = 4

x = -2

TempaskMPa = superheat1_cell.Offset(c, x).Value

Value1 = Tempask1 - TempaskMPa

Do While Value1 <> 0

    c = c + 1

        TempaskMPa = superheat1_cell.Offset(c, x).Value

      Value1 = Tempask1 - TempaskMPa

    Loop

    x = x + 1

    volume = superheat1_cell.Offset(c, x).Value

    MsgBox " The Temperature is " & Tempask1 & "The Pressure is " & pressask1 & "The volume is " & volume

    MsgBox "Superheated"

    Range("D11").Value = "Superheated"

Range("D10").Value = volume

End If

End Sub

Liquid RTPM Psat 12.025 Start Here m3ikg. Temp. Meresa. Igud vapor. Igud. Evap. Vapor igud, Evap. Vapor Iguid. Evap. Vapor 0,001 8.555 8.790 1 316 240 8.189 8556 0.001 .07St 0.3551 6738 0001 27 0.19 2.139 0001134 783 218 Part A Sheet1 Part B 77985 $2.99 2 2 62992 A 2528 3 02246 95EE9 87903 4334 83 23043 104.83 24417 23465 03672 8S5 385567 2 7 21 19 2 7 2008.9 0.8313 70759 79082 31202 50386 2 21758 24683 233.07 7754 0.2153 740.02 741.02 031.7 2 7 20905 335 10020 001 01900 10209 25020 7303 20112 27772 2.32 4A40 G5001 11235 0.1739 785.19 27814 2.875 43572 65447

Explanation / Answer

See first I do have the data file,

The coding is okay error related to data value.

For example I test with temperature 1 and pressure 1 and excel sheet all data 1 then it is working.

Therefore error related to data or some manipulation, please provide the data file.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote