ZH
ZH
Dim ws As Worksheet
Dim resultSheet As Worksheet
Dim lastRow As Long
Dim pierLabel As String
Dim outputCase As String
Dim maxPValueGk As Double
Dim maxPValueQk As Double
Dim maxPValueENVWL As Double
Dim currentPValue As Double
Dim condition As Double
Dim Qk As Double
Dim resultRow As Long
' Set the last row with data in column A (change "A" to the appropriate column)
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
' Assuming the pier label is in column A, output case in column B, and P
value in column C
pierLabel = ws.Cells(i, 1).Value
outputCase = ws.Cells(i, 2).Value
currentPValue = ws.Cells(i, 3).Value
' Check if the current P value is greater than the maxPValue for the same
pier and output case
If outputCase = "Gk" Then
If currentPValue > maxPValueGk Then
maxPValueGk = 1.05 * currentPValue / 9.81
End If
ElseIf outputCase = "Qk" Then
If currentPValue > maxPValueQk Then
maxPValueQk = WorksheetFunction.Ceiling((1.05 * currentPValue /
9.81), 10)
End If
End If
End If
Else
Qk = maxPValueQk - WorksheetFunction.Ceiling(condition, 10)
End If
' If the next row has a different pier label or it's the last row, print
the result to the new sheet
If ws.Cells(i + 1, 1).Value <> pierLabel Or i = lastRow Then
' Print or use the results to the new sheet
resultSheet.Cells(resultRow, 1).Value = pierLabel
resultSheet.Cells(resultRow, 2).Value =
WorksheetFunction.Ceiling(maxPValueGk, 10)
resultSheet.Cells(resultRow, 3).Value = Qk
' Increment resultRow for the next set of results
resultRow = resultRow + 1