sheet1表中有产品A,B,C。。。。。,产品分为优和差两类,现在要根据sheet1表中的记录(如图1),用公式将差的产品在sheet2中自动列出来(如图2).
------解决方案--------------------
Sub main()
Dim l As Long, i As Long, j As Long, c
Sheet2.Activate
Cells.ClearContents
l = 1 'Sheet2的行计数
With Sheet1
For j = 2 To 3
For i = 2 To .[A65530].End(xlUp).Row
If Len(.Cells(i, j)) Then
For Each c In Split(.Cells(i, j), ",")
Cells(l, 1) = c '等级
Cells(l, 2) = .Cells(i, 1) '日期
Cells(l, 3) = .Cells(1, j) '优差
l = l + 1
Next c
End If
Next i
l = l + 1
Next j
End With
End Sub