|
发表于 2013-3-22 19:23
|
显示全部楼层
本楼为最佳答案
simonshaw 发表于 2013-3-22 12:30
大师,新附件能看得懂么?
Sub TJ()
For I = Range("DO:DO").Column To Range("HK:HK").Column
If Application.Sum(Range(Cells(13, I), Cells(22, I))) = 0 Then
W = I
Exit For
End If
Next
S = Range("K13").Value
For I = Range("DO:DO").Column To Range("HK:HK").Column
Range(Cells(13, I), Cells(22, I)).Copy Cells(13, W)
W = W + 1
T = Application.Sum(Range(Cells(13, I), Cells(22, I)))
If S - T < 0 Then
For J = 13 To 22
If Cells(J, I) <> "" Then Cells(J, W - 1) = S
Next
Exit For
Else
S = S - T
End If
Next
For I = Range("DO:DO").Column To Range("HK:HK").Column
If Application.Sum(Range(Cells(13, I), Cells(22, I))) = 0 Then Columns(I).Hidden = True
Next
End Sub |
|