|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Private Sub CommandButton5_Click()
Dim b()
ReDim b(1 To 100)
al = Sheet4.Application.CountA(Range("a:a"))
For n = 2 To al
ta = 0
For m = 2 To 28 Step 2
Set frng1 = Sheet3.Range("a2:g100").Find(Sheet4.Cells(n, m), , , xlWhole)
If Not frng1 Is Nothing Then
b(m) = frng1.Offset(0, 6).Value * Sheet4.Cells(n, m + 1)
X = b(m)
ta = ta + X
End If
Next
Sheet4.Cells(n, "av") = ta
Next
rs = Sheet4.Application.CountA([a:a])
Sheet4.Range("a1:av" & rs).Copy
Sheet6.Activate
Sheet6.UsedRange.ClearContents
Sheet6.Paste cells(a1)
End Sub
有时在运行Sheet4.Range("a1:av" & rs).Copy时报,有时在Sheet6.Paste时报。我是VBA初学者,业务上需要。请大神指点
|
|