東西線沿線的:
Public Sub CubeColumnC
Dim wb as Workbook
Dim ws as Worksheet
Dim sourceRange as Range
Dim sourceArr()
Dim i as long
Set wb = ThisWorkbook
Set ws = wb.Sheets("Sheet1") 'change to as needed
Set sourceRange = ws.Range("C3:C21")
'Assign column c values to array
sourceArr = Application.Transpose(sourceRange.Value)
With ws
For i = Lbound(sourceArr) To Ubound(sourceArr) 'Write back out to col D
If .Cells(2+i, "C") = vbNullString Then 'if blank
.Cells(2+i, "D") = "-"
Else
.Cells(2+i,"D") = sourceArr(i)^3 'Calc the Cube value
End If
Next i
End With
End Sub
我忽略了你C3 = C3,因爲這始終是真實的,修改您認爲合適的。
編輯:Application.WorksheetFunction.Power(sourceArr(I),3)改爲sourceArr(我)^ 3立方值
任何機構可以幫助我PLZ –
不要寫出公式的範圍內而是將結果寫入範圍? – QHarr
如何?請你可以寫樣本代碼? –