我对此有点陌生。我将如何获取列并将其单元格数据放入整数并遍历该范围内的所有值以将其放入函数中以将结果输出到 excel 工作簿中的另一列中。所以我的输出列将是整个 Comm 列,使用列 G、J 和 K 作为函数的输入=100000*slotNumber+300*xpos+ypos
A B C D E F G H I J K
1 Proc Equip Operat Shift Comm Casette SlotNumber Diam Measure XPos YPos
2
3'
所以想如果我获取每个值并创建一个 for 循环,我可以获取这些值并以某种方式完成所有这些,只是不知道如何!谢谢,麻烦您了!
编辑:我存储了所有列,现在我必须将数组值一一传递给函数,对于公式Z = 100000*slotArr(i)+300xList(i)+yList(i)
,或者我可以将它放在 for 循环中。
编辑:将函数放在循环中......我得到一个对象超出范围错误......在函数的行。
Sub cmdMeans_Click()
Dim i As Long, j As Long
Dim slotList As Range, slotArr() As Variant, xList As Range, xArr() As Variant
Dim yList As Range, yArr() As Variant, cArr() As Variant
Set slotList = Range("P2", Range("P2").End(xlDown))
slotArr() = slotList.Value
Set xList = slotList.Offset(0, 4)
xArr() = xList.Value
Set yList = slotList.Offset(0, 5)
yArr() = yList.Value
'Only one counter required because of the dependancy on the range slotList
For i = 2 To UBound(slotArr, 1)
'Dimensioning Array
ReDim cArr(UBound(slotArr, 1), 1)
cArr(i, 1) = (100000 * slotArr(i, 1)) + (300 * xList(i, 1)) + yList(i, 1)
'MsgBox ("Comment Cell Value" & cArr(i, 1))
Next
'Resizing Array
ReDim Preserve cArr(i)
'This is where the new values will be written to the comment column
Dim cRng As Range
Set cRng = Range(Cells(14, 1), Cells(UBound(cArr(i))))
cRng.Value = Application.Transpose(cArr)
End Sub