For i = star To num Step 1 ' 每次跳1步,优化速度
If Sheet10.Cells(i, 4) <> "" And Sheet10.Cells(i, 15) <> "√" And Sheet10.Cells(i, 4) >= Sheet10.Cells(6, 10) And Sheet10.Cells(i, 4) <= Sheet10.Cells(6, 12) Then
' 从Sheet10读取需要的数据到数组
rngValue1 = Sheet10.Range(Sheet10.Cells(i, 4), Sheet10.Cells(i + 1, 4)).Value '记账日期到数组
rngValue2 = Sheet10.Range(Sheet10.Cells(i, 7), Sheet10.Cells(i + 1, 7)).Value '摘要到数组
If Sheet10.Cells(i, 8) = "" Then
rngValue3 = Sheet10.Range(Sheet10.Cells(i, 17), Sheet10.Cells(i + 1, 17)).Value '借方科目代码到数组
Else
rngValue3 = Sheet10.Range(Sheet10.Cells(i, 16), Sheet10.Cells(i + 1, 16)).Value
End If
If Sheet10.Cells(i, 8) = "" Then
rngValue4 = Sheet10.Range(Sheet10.Cells(i, 9), Sheet10.Cells(i + 1, 9)).Value '借方金额到数组
Else
rngValue4 = Sheet10.Range(Sheet10.Cells(i, 8), Sheet10.Cells(i + 1, 8)).Value
End If
rngValue5 = Sheet10.Range(Sheet10.Cells(i, 5), Sheet10.Cells(i + 1, 5)).Value '隶属公司到数组
rngValue6 = Sheet10.Range(Sheet10.Cells(i, 6), Sheet10.Cells(i + 1, 6)).Value '隶属机构到数组
If Sheet10.Cells(i, 8) = "" Then
rngValue7 = Sheet10.Range(Sheet10.Cells(i, 16), Sheet10.Cells(i + 1, 16)).Value '贷方科目代码到数组
Else
rngValue7 = Sheet10.Range(Sheet10.Cells(i, 17), Sheet10.Cells(i + 1, 17)).Value
End If
UnprotectSheet '解除保护
' 将借方数据写入凭证处理Sheet8
Sheet8.Cells(j, 7).Value = rngValue1 '记账日期
Sheet8.Cells(j, 9).Value = rngValue2 '摘要
Sheet8.Cells(j, 10).Value = rngValue3 '借方科目
Sheet8.Cells(j, 13).Value = rngValue4 '借方金额
Sheet8.Cells(j, 18).Value = rngValue5 '隶属公司
Sheet8.Cells(j, 19).Value = rngValue6 '隶属机构
Sheet8.Cells(j, 20).Resize.Value = "日记账生成" '数据来源
j = j + 1
' 将贷方数据写入凭证处理Sheet8
Sheet8.Cells(j, 7).Value = rngValue1 '记账日期
Sheet8.Cells(j, 9).Value = rngValue2 '摘要
Sheet8.Cells(j, 10).Value = rngValue7 '贷方科目
Sheet8.Cells(j, 14).Value = rngValue4 '贷方金额
Sheet8.Cells(j, 18).Value = rngValue5 '隶属公司
Sheet8.Cells(j, 19).Value = rngValue6 '隶属机构
Sheet8.Cells(j, 20).Resize.Value = "日记账生成" '数据来源
j = j + 1
Sheet10.Cells(i, 15) = "√" ' 反写日记账生成状态
End If
Next i