|
Sub 报价单()
Application.ScreenUpdating = False
Dim ar As Variant
Dim br()
Dim rn As Range
With Sheets("造价")
r = .Cells(Rows.Count, 1).End(xlUp).Row
If r < 2 Then MsgBox "造价表为空!": End
ar = .Range("a1:h" & r)
End With
ReDim br(1 To UBound(ar), 1 To 8)
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> "" Then
n = n + 1
br(n, 1) = n
br(n, 2) = ar(i, 2)
br(n, 3) = ar(i, 3)
br(n, 4) = "米"
br(n, 5) = ar(i, 4)
br(n, 6) = ar(i, 5)
br(n, 7) = ar(i, 8)
End If
Next i
With Sheets("报价单")
rs = .Cells(Rows.Count, 6).End(xlUp).Row
.Rows("5:" & rs - 1).Delete
.Rows(5).Resize(n).Insert Shift:=xlDown
.[a5].Resize(n, UBound(br, 2)) = br
.[a5].Resize(n, UBound(br, 2)).Borders.LineStyle = 1
.Cells(n + 5, 7).FormulaR1C1 = "=SUM(R[-" & n & "]C:R[-1]C)"
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub |
|