|
楼主 |
发表于 2011-9-12 20:29
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Private Sub CommandButton2_Click()
With Sheets("最终效果")
Maxrow = 6
Rwct = Sheets("单户明细汇总").Range("C65536").End(xlUp).Row
For i = Maxrow To Rwct
If Sheets("单户明细汇总").Cells(1 + i, 2) <> "" Then
Cells(4, 1) = Right(Year(Sheets("单户明细汇总").Cells(7, 2)), 2) '年2位
Cells(i, 1) = Month(Sheets("单户明细汇总").Cells(1 + i, 2)) '月2位
Cells(i, 10) = Sheets("单户明细汇总").Cells(i - 4, 12) '利率
End If
If Sheets("单户明细汇总").Cells(1 + i, 2) <> "" Then
Cells(i, 2) = Day(Sheets("单户明细汇总").Cells(6 + i, 2)) '日2位
Cells(6, 4) = Right(Year(Sheets("单户明细汇总").Cells(2, 10)), 2) '年2位
Cells(6, 5) = Month(Sheets("单户明细汇总").Cells(2, 10)) '月2位
Cells(6, 6) = Day(Sheets("单户明细汇总").Cells(2, 10)) '日2位
Cells(6, 7) = Right(Year(Sheets("单户明细汇总").Cells(2, 11)), 2) '年2位
Cells(6, 8) = Month(Sheets("单户明细汇总").Cells(2, 11)) '月2位
Cells(6, 9) = Day(Sheets("单户明细汇总").Cells(2, 11)) '日2位
End If
If Sheets("单户明细汇总").Cells(1 + i, 6) <> "" Then
Cells(i, 29) = Right(Year(Sheets("单户明细汇总").Cells(1 + i, 6)), 2) '年2位
End If
If Sheets("单户明细汇总").Cells(1 + i, 6) <> "" Then
Cells(i, 30) = Month(Sheets("单户明细汇总").Cells(1 + i, 6)) '月2位
End If
If Sheets("单户明细汇总").Cells(1 + i, 6) <> "" Then
Cells(i, 31) = Day(Sheets("单户明细汇总").Cells(1 + i, 6)) '日2位
End If
If Sheets("单户明细汇总").Cells(i + 1, 4) <> "" And Abs(Val(Sheets("单户明细汇总").Cells(i + 1, 4))) >= 0 Then '借方金额分栏填充
VaToBranch CDbl(Val(Sheets("单户明细汇总").Cells(i + 1, 4))), i, 11, 19
End If
If Sheets("单户明细汇总").Cells(i + 1, 5) <> "" And Abs(Val(Sheets("单户明细汇总").Cells(i + 1, 5))) >= 0 Then '贷方金额分栏填充
VaToBranch CDbl(Val(Sheets("单户明细汇总").Cells(i + 1, 5))), i, 20, 28
End If
If Sheets("单户明细汇总").Cells(i + 1, 7) <> "" And Abs(Val(Sheets("单户明细汇总").Cells(i + 1, 7))) >= 0 Then '结存金额分栏填充
VaToBranch CDbl(Val(Sheets("单户明细汇总").Cells(i + 1, 7))), i, 32, 40
End If
If Sheets("单户明细汇总").Cells(i + 1, 8) <> "" And Abs(Val(Sheets("单户明细汇总").Cells(i + 1, 8))) >= 0 Then '利息金额分栏填充
VaToBranch CDbl(Val(Sheets("单户明细汇总").Cells(i + 1, 8))), i, 41, 47
End If
Next i
End With
End Sub
这是金额分栏的代码,有老师帮忙吗,精简一下代码,谢谢 |
|