wdjwt 发表于 2017-7-19 16:15
就是上述代码中的:
arr(d(CStr(rng(i, j))), j - 2) = rng(i, j)
arr(d(CStr(rng(i, j))), j - 1) = rng ...
要求是排列与A列相同的股票代码要在同一行里
For i = 1 To UBound(rng)
d(CStr(rng(i, 1))) = i '这里的i是记录A列中股票代码在数组rng的位置
Next i
下面的i是有顺序的序号,而d(CStr(rng(i, j)))是返回C列和D列中股票代码在rng数组中用字典所记录的位置
For j = 3 To 5 Step 2
For i = 1 To Cells(65536, j).End(xlUp).Row - 2
If d(CStr(rng(i, j))) <> "" Then
arr(d(CStr(rng(i, j))), j - 2) = rng(i, j)
arr(d(CStr(rng(i, j))), j - 1) = rng(i, j + 1)
End If
Next i
Next j
arr(d(CStr(rng(i, j))), j - 2) = rng(i, j)
arr(d(CStr(rng(i, j))), j - 1) = rng(i, j + 1)
所以不能用i(是有顺序的序号)
代替d(CStr(rng(i, j))) 股票代码在rng数组中用字典所记录的位置
arr(i, j - 2) = rng(i, j)
arr(i, j - 1) = rng(i, j + 1) |