我的数据集格式为“Ping 172.123.123.123 = [150ms]”。我怎样才能得到“[”和“]”中的内容之和?我有很多行和列,希望得到所有ping的SUM或AVERAGE
中的示例答案 0 :(得分:1)
假设每个单元以]
结束tsc *.ts --watch
答案 1 :(得分:0)
这将对每列进行求和,并将总数添加到每列的最后一行:
Sub foo()
Dim openPos As Integer
Dim closePos As Integer
Dim midBit As String
Dim Str As String
Dim Extract_value As Integer
LastRow = Sheet1.Cells(Sheet1.Rows.Count, "A").End(xlUp).Row
LastCol = Sheet1.Cells(1, Sheet1.Columns.Count).End(xlToLeft).Column
x = 1
For x = 1 To LastCol
For i = 1 To LastRow
Str = Sheet1.Cells(i, x).Value
On Error Resume Next
openPos = InStr(Str, "[")
On Error Resume Next
closePos = InStr(Str, "m")
On Error Resume Next
midBit = Mid(Str, openPos + 1, closePos - openPos - 1)
If openPos <> 0 And Len(midBit) > 0 Then
Extract_value = Extract_value + midBit
End If
Sheet1.Cells(LastRow + 1, x).Value = Extract_value
Next i
Next x
End Sub