|
楼主 |
发表于 2019-12-18 15:45
|
显示全部楼层
本帖最后由 y1983y 于 2019-12-18 18:32 编辑
Sub aa()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlManual
With Sheet1
r = .Range("a" & Rows.Count).End(xlUp).Row
c = .Cells(1, Columns.Count).End(xlToLeft).Column
arr = .Range("a1").Resize(r, c)
ReDim brr(1 To UBound(arr) * c, 1 To 3)
ii = 0
For j = 3 To c
For i = 3 To UBound(arr)
If arr(i, j) <> "" And arr(2, j) <> "" Then
ii = ii + 1
brr(ii, 1) = arr(1, j)
brr(ii, 2) = arr(i, 2)
brr(ii, 3) = Val(arr(i, j)) * Val(arr(2, j))
End If
Next i
Next j
End With
With Sheet2
irow = .Range("a" & Rows.Count).End(xlUp).Row
icol = .Cells(1, Columns.Count).End(xlToLeft).Column
.Range("a2").Resize(irow, icol).ClearContents
.Range("a2").Resize(ii, 3) = brr
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
End Sub
将原brr(ii, 3) = arr(i, j) 改为brr(ii, 3) = Val(arr(i, j)) * Val(arr(2, j))各位大侠,还有其他方法吗?欢迎指导,谢谢!
|
|