循环收集标签和计算
Looping to Collect Labels and Calculations
编程目标:
1) 循环并存储个人统计数据:
一个。扫描序列号,偏移并为每个收集以下信息:
一世。 PL#
二。固件版本
三。容量(下面单元格中的任何内容)
四。技术(下面单元格中的任何内容)
v。电池#
对于每个单独的 PL,以下计算...
六。平均、最小、最大(* 充电状态百分比)
七。平均值、最小值、最大值(温度)
八。 Min, Max, Avg(I 开始充电 (A))
六。出现次数相等。时间“=0”,“(1,419)”,“(420,839)”,“=840”
x。低级别“是”和“否”的出现次数
xi.是/(是+否)的比率
十二。 Sum(Disch.Ah-)
十三。 Sum(Ah+电荷)
十四。 (Ah+ / Ah-)
比率
2) 输出table到一个新的sheet:
一个。使用 headers 分别创建 table i-xii
b。每个单独的 PL# 及其各自的价值 i-xii
c。相等之和。所有数据的存储桶时间
3) 将图表输出到新的 sheet:
一个。所有日期 (y) 和 * % 充电状态 (x) 二维线图,y 轴 0-100,
100 处的绿色常量线和 20 处的常量红线
b。所有日期和温度 2D 线图,在 138
处有一条常量红线
我正在研究 (1)。这就是我扫描和收集每个块的方式...
Sub GetData()
Dim ArrPK() As String, SearchString As String
Dim SerialNo As Range, aCell As Range
Dim ws As Worksheet
Dim PkCounter As Long
Dim LstBox As msforms.ListBox
Set ws = ThisWorkbook.Sheets("Sheet1")
SearchString = "Serial#"
Set LstBox = UserForm1.ListBox1
PkCounter = 1
With ws
Set SerialNo = .Range("A1:A" & .Cells(.Rows.Count, "A").End(xlUp).Row)
For Each aCell In SerialNo
If aCell.Value2 = SearchString Then
ReDim Preserve ArrPK(1 To 5, 1 To PkCounter)
ArrPK(1, PkCounter) = aCell.Offset(0, 1) 'Serial#
ArrPK(2, PkCounter) = aCell.Offset(1, 1) 'Firmware#
ArrPK(3, PkCounter) = aCell.Offset(3, 1) 'Capacity
ArrPK(4, PkCounter) = aCell.Offset(3, 3) 'Technology
ArrPK(5, PkCounter) = aCell.Offset(3, 11) 'Battery#
'Collected information labels, now run calculations...
PkCounter = PkCounter + 1
End If
Next
End With
我想做什么:。我想用收集到的标签和相应的计算输出一个 table。到目前为止我的循环得到了标签。
示例文件:
https://drive.google.com/open?id=1vDqnt2aHL06xB2Fg9k5MZ2WeCefqQZ1n1
这需要更多编码,您可以对其进行更多参数化,但如果导出 excel 文件格式不变,保持简单也有好处。我计算了平均温度并将其插入到您的数组中。收集完所有数据后,您需要转置数组并将其粘贴到 sheet:
Sub GetData()
Dim ArrPK() As String, SearchString As String
Dim SerialNo As Range, aCell As Range
Dim ws As Worksheet
Dim PkCounter As Long
'Dim LstBox As msforms.ListBox
Dim rng As Range
Set ws = ThisWorkbook.Sheets("Sheet1")
SearchString = "Serial#"
'Set LstBox = UserForm1.ListBox1
PkCounter = 1
With ws
Set SerialNo = .Range("A1:A" & .Cells(.Rows.Count, "A").End(xlUp).Row)
For Each aCell In SerialNo
If aCell.Value2 = SearchString Then
ReDim Preserve ArrPK(1 To 6, 1 To PkCounter)
ArrPK(1, PkCounter) = aCell.Offset(0, 1) 'Serial#
ArrPK(2, PkCounter) = aCell.Offset(1, 1) 'Firmware#
ArrPK(3, PkCounter) = aCell.Offset(3, 1) 'Capacity
ArrPK(4, PkCounter) = aCell.Offset(3, 3) 'Technology
ArrPK(5, PkCounter) = aCell.Offset(3, 11) 'Battery#
'define the data block for the battery
Set rng = aCell.CurrentRegion 'data block for one battery
Set rng = rng.Offset(6, 0)
Set rng = rng.Resize(rng.Rows.Count - 6, rng.Columns.Count)
'now range is defined, run the calculations using the worksheet functions, or use a loop over the range columns
'### calculate avg, min and max temperature (8th column in block)
ArrPK(6, PkCounter) = Application.WorksheetFunction.Average(rng.Columns(8)) 'average temperature
PkCounter = PkCounter + 1
End If
Next
End With
End Sub
编程目标:
1) 循环并存储个人统计数据:
一个。扫描序列号,偏移并为每个收集以下信息: 一世。 PL#
二。固件版本
三。容量(下面单元格中的任何内容)
四。技术(下面单元格中的任何内容)
v。电池#
对于每个单独的 PL,以下计算...
六。平均、最小、最大(* 充电状态百分比)
七。平均值、最小值、最大值(温度)
八。 Min, Max, Avg(I 开始充电 (A))
六。出现次数相等。时间“=0”,“(1,419)”,“(420,839)”,“=840”
x。低级别“是”和“否”的出现次数
xi.是/(是+否)的比率
十二。 Sum(Disch.Ah-)
十三。 Sum(Ah+电荷)
十四。 (Ah+ / Ah-)
比率2) 输出table到一个新的sheet:
一个。使用 headers 分别创建 table i-xii
b。每个单独的 PL# 及其各自的价值 i-xii
c。相等之和。所有数据的存储桶时间
3) 将图表输出到新的 sheet:
一个。所有日期 (y) 和 * % 充电状态 (x) 二维线图,y 轴 0-100,
100 处的绿色常量线和 20 处的常量红线
b。所有日期和温度 2D 线图,在 138
处有一条常量红线我正在研究 (1)。这就是我扫描和收集每个块的方式...
Sub GetData()
Dim ArrPK() As String, SearchString As String
Dim SerialNo As Range, aCell As Range
Dim ws As Worksheet
Dim PkCounter As Long
Dim LstBox As msforms.ListBox
Set ws = ThisWorkbook.Sheets("Sheet1")
SearchString = "Serial#"
Set LstBox = UserForm1.ListBox1
PkCounter = 1
With ws
Set SerialNo = .Range("A1:A" & .Cells(.Rows.Count, "A").End(xlUp).Row)
For Each aCell In SerialNo
If aCell.Value2 = SearchString Then
ReDim Preserve ArrPK(1 To 5, 1 To PkCounter)
ArrPK(1, PkCounter) = aCell.Offset(0, 1) 'Serial#
ArrPK(2, PkCounter) = aCell.Offset(1, 1) 'Firmware#
ArrPK(3, PkCounter) = aCell.Offset(3, 1) 'Capacity
ArrPK(4, PkCounter) = aCell.Offset(3, 3) 'Technology
ArrPK(5, PkCounter) = aCell.Offset(3, 11) 'Battery#
'Collected information labels, now run calculations...
PkCounter = PkCounter + 1
End If
Next
End With
我想做什么:。我想用收集到的标签和相应的计算输出一个 table。到目前为止我的循环得到了标签。
示例文件:
https://drive.google.com/open?id=1vDqnt2aHL06xB2Fg9k5MZ2WeCefqQZ1n1
这需要更多编码,您可以对其进行更多参数化,但如果导出 excel 文件格式不变,保持简单也有好处。我计算了平均温度并将其插入到您的数组中。收集完所有数据后,您需要转置数组并将其粘贴到 sheet:
Sub GetData()
Dim ArrPK() As String, SearchString As String
Dim SerialNo As Range, aCell As Range
Dim ws As Worksheet
Dim PkCounter As Long
'Dim LstBox As msforms.ListBox
Dim rng As Range
Set ws = ThisWorkbook.Sheets("Sheet1")
SearchString = "Serial#"
'Set LstBox = UserForm1.ListBox1
PkCounter = 1
With ws
Set SerialNo = .Range("A1:A" & .Cells(.Rows.Count, "A").End(xlUp).Row)
For Each aCell In SerialNo
If aCell.Value2 = SearchString Then
ReDim Preserve ArrPK(1 To 6, 1 To PkCounter)
ArrPK(1, PkCounter) = aCell.Offset(0, 1) 'Serial#
ArrPK(2, PkCounter) = aCell.Offset(1, 1) 'Firmware#
ArrPK(3, PkCounter) = aCell.Offset(3, 1) 'Capacity
ArrPK(4, PkCounter) = aCell.Offset(3, 3) 'Technology
ArrPK(5, PkCounter) = aCell.Offset(3, 11) 'Battery#
'define the data block for the battery
Set rng = aCell.CurrentRegion 'data block for one battery
Set rng = rng.Offset(6, 0)
Set rng = rng.Resize(rng.Rows.Count - 6, rng.Columns.Count)
'now range is defined, run the calculations using the worksheet functions, or use a loop over the range columns
'### calculate avg, min and max temperature (8th column in block)
ArrPK(6, PkCounter) = Application.WorksheetFunction.Average(rng.Columns(8)) 'average temperature
PkCounter = PkCounter + 1
End If
Next
End With
End Sub