我對此有點新。我將如何取出列,並將其單元格數據是一個整數並遍歷該範圍中的所有值,以將其放入一個函數中,以便將結果輸出到Excel工作簿中的另一列中。所以,我的輸出列將使用列G,J和K爲投入的功能=100000*slotNumber+300*xpos+ypos
VBA Excel Store Range as Array,提取公式的單元格值。其他變量的偏移量
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
你能更清晰地格式化您的問題或可能提供屏幕截圖?我不知道你在問什麼。 – JustinJDavies
我無法提交照片,但我可以通過電子郵件,因爲論壇不會讓我。所以上面的字母代表了列。 C列(插槽號)是excel列的值加載,我想要一個數組來存儲所有這些值,然後還將值存儲在XP和YPos的J&K列中。得到這些數據之後,我想將它們全部傳遞給一個新的數組輸出的函數。然後將輸出轉換爲一個範圍並將其放置在Comm的列A中。 – user2027945
什麼是您的工作表列中的「條形碼」類型垂直? :$ – bonCodigo