|
Private Sub UserForm_Initialize()
Dim ar As Variant
Dim br()
rr = Array("节次", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日")
With Sheets("汇总")
r = .Cells(Rows.Count, 1).End(xlUp).Row
y = .Cells(4, Columns.Count).End(xlToLeft).Column
ar = .Range(.Cells(1, 1), .Cells(r, y))
For j = 0 To UBound(rr)
ListView1.ColumnHeaders.Add , , rr(j), 90 'Sheets("物料库存数据").Cells(3, j).Width
Next
ListView1.View = lvwReport
ListView1.FullRowSelect = True
ListView1.Gridlines = True
ReDim br(1 To 14, 1 To 8)
br(1, 1) = "节次"
For j = 2 To 14
br(j, 1) = ar(4, j)
Next j
zd = ActiveCell.Value
xm = Split(zd, Chr(10))(1)
y = 1
For j = 2 To UBound(ar, 2) Step 13
y = y + 1
For s = j To j + 12
If IsNumeric(ar(4, s)) Then
xh = ar(4, s) + 2
ElseIf ar(4, s) = "早读" Then
xh = 2
ElseIf InStr(ar(4, s), "晚") > 0 Then
xh = Right(ar(4, s), 1) + 11
End If
For i = 5 To UBound(ar)
If ar(i, s) <> "" Then
If InStr(ar(i, s), Chr(10)) > 0 Then
If InStr(ar(i, s), xm) > 0 Then
br(xh, y) = Split(ar(i, s), Chr(10))(0) & ar(i, 1)
End If
End If
End If
Next i
Next s
Next j
For i = 2 To UBound(br)
Set Itm = ListView1.ListItems.Add
Itm.text = br(i, 1)
For j = 2 To UBound(br, 2)
Itm.SubItems(j - 1) = br(i, j)
Next j
Next i
End With
End Sub
|
|