0% found this document useful (0 votes)
44 views2 pages

ZH

This document contains code to analyze pier data from a raw data sheet and output summarized results to a new results sheet. It loops through each row of pier data, tracks the maximum P-values for each pier label and output case, calculates a Qk value using a formula, and outputs the summarized values for each unique pier label.

Uploaded by

dccd8801
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views2 pages

ZH

This document contains code to analyze pier data from a raw data sheet and output summarized results to a new results sheet. It loops through each row of pier data, tracks the maximum P-values for each pier label and output case, calculates a Qk value using a formula, and outputs the summarized values for each unique pier label.

Uploaded by

dccd8801
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Sub pierforce()

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 worksheet (change "Sheet1" to your sheet name)


Set ws = ThisWorkbook.Sheets("raw data")

' Create a new sheet for results


Set resultSheet = Sheets.Add(After:=Sheets(Sheets.Count))
resultSheet.Name = "Results"

' 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

' Initialize resultRow for the new sheet


resultRow = 1

' Add titles to the columns


resultSheet.Cells(resultRow, 1).Value = "Pier Label"
resultSheet.Cells(resultRow, 2).Value = "Gk"
resultSheet.Cells(resultRow, 3).Value = "Qk"

' Increment resultRow for the next set of results


resultRow = resultRow + 1

' Loop through each row


For i = 1 To lastRow

' 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

ElseIf outputCase = "ENV-WL" Then


If currentPValue > maxPValueENVWL Then
maxPValueENVWL = WorksheetFunction.Ceiling((1.05 * currentPValue /
9.81), 10)

End If

End If

' Calculate the Qk based on the plug in formula


Qk = WorksheetFunction.Ceiling((maxPValueQk + 0.5 * maxPValueENVWL), 10)
condition = maxPValueQk - 0.5 * maxPValueENWL

If condition >= 0 Then

Qk = maxPValueQk + WorksheetFunction.Ceiling(condition, 10)

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

' Reset maxPValues for the next pier


maxPValueGk = 0
maxPValueQk = 0
maxPValueENVWL = 0
End If
Next i
End Sub

You might also like