我正在尝试在宏中编写代码。
对于范围内的每一行:
我试图连续选择非空单元格。
对于这些单元格,请选择最小值n_1
。
给定乘法因子a
创建一个从最小值开始的等间隔数字的数组(与非空行长度相同),即(n_k = (a^k)*n_1
)。
沿着这些方向的东西
Dim a As Range, b As Range, number_of_elements as Integer
Set a = Range()
For Each b In a.Rows
Dim newarray as Variant 'initialize new array
arr = select_non_empty_cells(b) 'select non empty cells
number_of_elements = Ubound(arr) 'get number of elements
ReDim newarray(1 To number_of_elements) As Integer 'set the dimension
min_val = WorksheetFunction.Min(arr.Value) 'pick minimum value
For counter = 1 To number_of_elements 'create new array with equally spaced numbers
newarray(counter) = min_val*1.25^counter 'multiplying factor
Next counter
arr.Value = newarray.Value 'set the non empty range to new values
Next
以下是我的数据的样子。因此,对于第一行,我将选择1033.2(最小值)并创建具有均匀间隔的相同长度的5个元素的新数组。第二行也是如此。