期待效果
vba
Sub gettogether()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim count As Integer '学科个数
Dim num_video As Integer
k = 2
Dim str1 As String '日期链接科目
Dim str2 As String '学科
Dim tmp As String '日期链接科目
Dim flag As Boolean
str1 = ""
str2 = ""
tmp = ""
For j = 2 To 151 '最后加一条记录
tmp = Sheet1.Cells(j, 1) & Sheet1.Cells(j, 2)
If tmp = str1 Then ' 大于等于第二个
str2 = str2 + " " + Sheet1.Cells(j, 3)
count = count + 1
num_video = num_video + Sheet1.Cells(j, 4)
Else '第一个新的
Sheet1.Cells(k, 7) = Sheet1.Cells(j - 1, 1) '处理上一次的数据
Sheet1.Cells(k, 8) = Sheet1.Cells(j - 1, 2) '处理上一次的数据
Sheet1.Cells(k, 9) = "精品" '处理上一次的数据
Sheet1.Cells(k, 10) = str2
Sheet1.Cells(k, 11) = count
Sheet1.Cells(k, 12) = num_video
k = k + 1 '新的数据初始化
str1 = tmp
str2 = Sheet1.Cells(j, 3)
count = 1
num_video = Sheet1.Cells(j, 4)
End If
Next
End Sub