|
Sub SaveRKD()
Dim Row_Product As Integer
Dim i As Integer
'如果项目编号和项目名称不为空,则保存数据
If Sheets("登记单").Cells(3, 2) <> "" And Sheets("登记单").Cells(6, 1) <> 0 Then
Row_Product = Application.WorksheetFunction.CountA(Range("A6:A9")) + 6
With Sheets("具体清单")
Set Rng = .[D1048576].End(xlUp)
Rng.Offset(1, 6) = Sheets("登记单").[E10] '合计金额
Rng.Offset(1, 8) = Sheets("登记单").[C11] '经手人
For i = 6 To Row_Product
If Not IsEmpty(Sheets("登记单").Cells(i, 1)) Then
k = i - 5
Rng.Offset(k, -3) = Sheets("登记单").[G2] '合同编号
Rng.Offset(k, -2) = Sheets("登记单").[F11] '日期
Rng.Offset(k, -1) = Sheets("登记单").Cells(i, 2) '项目名称
Rng.Offset(k, 0) = Sheets("登记单").Cells(i, 3) '项目类别
Rng.Offset(k, 1) = Sheets("登记单").Cells(i, 4) '项目特征描述
Rng.Offset(k, 2) = Sheets("登记单").Cells(i, 5) '计量单位
Rng.Offset(k, 3) = Sheets("登记单").Cells(i, 6) '单价
Rng.Offset(k, 4) = Sheets("登记单").Cells(i, 7) '工程量
Rng.Offset(k, 5) = Sheets("登记单").Cells(i, 8) '金额
Rng.Offset(k, 7) = Sheets("登记单").Cells(i, 9) '备注
End If
Next i
End With
MsgBox "保存成功!"
End If
End Sub
|
|