我写了子“ change_array”。当我尝试使用它change_array("A1:AX2",2,2,0.5,1)
并运行它时,出现“语法错误:无法编译”。
我尝试将“ As String”维用作“ cellref”,但并没有带来任何改善。
Public Sub change_array() 'Sub does not return value, only executes
Dim cellref As Range
Dim row_number As Long
Dim column_number As Long
Dim x As Double 'Number, which will be added or multiplied by chosen cell value in an array
Dim method As Integer 'One for multiplication, two for addition
If method = 1 Then
Cells(row_number, column_number) = Cells(row_number, column_number) * "x"
ElseIf method = 2 Then
Cells(row_number, column_number) = Cells(row_number, column_number) + "x"
End If
End Sub
预期结果将是所选数组(在本例中为B2)的对应值乘以0.5