稍加改进,可实现明细帐的同步,别忘了表"凭证信息汇总"里的第二个图标同时作废不用: Sub 导入汇总表()
Dim k As Long, c As Range
If Sheets("凭证信息录入").Cells(16, 8) = Sheets("凭证信息录入").Cells(16, 9) Then
If MsgBox("是否导入凭证信息汇总表?", vbYesNo) = vbNo Then Exit Sub With Sheets("凭证汇总总表") '以下代码前带点的都是对【凭证汇总总表】操作
Sheets("凭证汇总总表").Unprotect Password:="GYX"
k = .[D65536].End(xlUp).Row + 1
.Cells(k, 1) = [I2]
.Cells(k, 2) = DateSerial([C2], [d2], [e2])
.Cells(k, 3) = [a5]
.Cells(k, 9) = [f11]
.Cells(k, 10) = [i11]
For Each c In [h5:h10]
If c <> "" Then
.Cells(k, 4) = c.Offset(0, -6)
.Cells(k, 5) = c.Offset(0, -5)
.Cells(k, 6) = c.Offset(0, -4)
.Cells(k, 7) = c
k = k + 1
ElseIf c.Offset(0, 1) <> "" Then
.Cells(k, 4) = c.Offset(0, -3)
.Cells(k, 5) = c.Offset(0, -2)
.Cells(k, 6) = c.Offset(0, -1)
.Cells(k, 8) = c.Offset(0, 1)
k = k + 1
End If
Next
Sheets("凭证汇总总表").Protect Password:="GYX"
End With
With Sheets("凭证信息汇总") '以下代码前带点的都是对【凭证信息汇总】操作
Sheets("凭证信息汇总").Unprotect Password:="GYX"
k = .[D65536].End(xlUp).Row + 1
.Cells(k, 1) = [I2]
.Cells(k, 2) = DateSerial([C2], [d2], [e2])
.Cells(k, 3) = [a5]
.Cells(k, 9) = [f11]
.Cells(k, 10) = [i11]
For Each c In [h5:h10]
If c <> "" Then
.Cells(k, 4) = c.Offset(0, -6)
.Cells(k, 5) = c.Offset(0, -5)
.Cells(k, 6) = c.Offset(0, -4)
.Cells(k, 7) = c
k = k + 1
ElseIf c.Offset(0, 1) <> "" Then
.Cells(k, 4) = c.Offset(0, -3)
.Cells(k, 5) = c.Offset(0, -2)
.Cells(k, 6) = c.Offset(0, -1)
.Cells(k, 8) = c.Offset(0, 1)
k = k + 1
End If
Next
Sheets("凭证信息汇总").Protect Password:="GYX"
End With
If MsgBox("你确认凭证信息已导入信息汇总表吗?", vbYesNo) = vbNo Then Exit Sub
Range("A5:B10,D5:E10,G5:G10,H5:I10,I11").ClearContents
Range("A5").Select
Else
MsgBox "借货不平,请进行凭证的审核!", 1 + 64, "系统提示"
End If
End Sub |