|
本帖最后由 hfwufanhf2006 于 2019-4-28 16:31 编辑
先贴代码,后面还有具体要求:
Range("a12:k12").ClearContents
Range("a13:o100").ClearContents
Rem 下面这段用复制copy也可以
For i = 12 To Worksheets("数据").[a10000].End(xlUp).Row
Cells(i, 1) = Worksheets("数据").Cells(i, 1)
Cells(i, 2) = Worksheets("数据").Cells(i, 2)
Cells(i, 3) = Worksheets("数据").Cells(i, 3)
Cells(i, 4) = Worksheets("数据").Cells(i, 4)
Cells(i, 5) = Worksheets("数据").Cells(i, 5)
Cells(i, 6) = Worksheets("数据").Cells(i, 6)
Cells(i, 7) = Worksheets("数据").Cells(i, 7)
Cells(i, 8) = Worksheets("数据").Cells(i, 8)
Cells(i, 9) = Worksheets("数据").Cells(i, 9)
Cells(i, 10) = Worksheets("数据").Cells(i, 10)
Cells(i, 11) = Worksheets("数据").Cells(i, 11)
Next i
For i = 13 To Worksheets("数据").[L100000].End(xlUp).Row
s1 = Worksheets("数据").Cells(i, 12)
s2 = Worksheets("数据").Cells(i, 13)
s3 = Worksheets("数据").Cells(i, 14)
s4 = Worksheets("数据").Cells(i, 15)
Cells(i, 12) = s1
Cells(i, 13) = s2
Cells(i, 14) = s3
Cells(i, 15) = s4
hs = 12
For k = 12 To [a100000].End(xlUp).Row
If Cells(k, 1) = s4 Then
hs = k
Exit For
End If
Next k
If s3 = "春" Then
Cells(hs, 2) = Cells(hs, 2) & "/" & s1
Cells(hs, 3) = Cells(hs, 3) + s2
End If
If s3 = "夏" Then
Cells(hs, 4) = Cells(hs, 4) & "/" & s1
Cells(hs, 5) = Cells(hs, 5) + s2
End If
If s3 = "秋" Then
Cells(hs, 6) = Cells(hs, 6) & "/" & s1
Cells(hs, 7) = Cells(hs, 7) + s2
End If
If s3 = "冬" Then
Cells(hs, 8) = Cells(hs, 8) & "/" & s1
Cells(hs, 9) = Cells(hs, 9) + s2
End If
If IsEmpty(s3) Then
Cells(hs, 10) = Cells(hs, 10) & "/" & s1
Cells(hs, 11) = Cells(hs, 11) + s2
End If
Next i
具体要求:
1、所有数据均要在“数据”表中输入,不能在“结果呈现”中录入,因为最开始的代码就把“结果呈现”清屏了,输了也是白输;
2、“数据”表的数据单元格是要用来计算的,所有数字单元格需要保证设置正确。我发现你“数据”表的e12\f12\k12都有一个自定义的货币符号,计算时会出问题,需要改成数字、货币或者常规格式;3、代码得到的结果与你要求的完全相同,但你要求的红色并没有实现;
4、代码一定要放在”结果呈现“表中,不然所有涉及工作表前缀的引用都需要互换;
|
|