我有以下問題。我有一個帶有輸入字段的用戶窗體。用戶將輸入參與者的號碼。我有四組參加者:Excel VBA中填充陣列
Group A: 5 Group B: 6 Group C: 1 Group D: 2
每個參與者都應該被命名爲這樣的:{GA1,GA2,...,GD2}我想寫這個到的順序數組,然後使用該數組用名字填充單元格,但是我想出的所有單元都是四個for循環將其寫入數組,並且也失敗了。有一個更好的方法嗎?
Dim GA As Integer
Dim GB As Integer
Dim GC As Integer
Dim GD As Integer
Dim PartSum As Integer
GA = TextBox32.Value
GB = TextBox33.Value
GC = TextBox34.Value
GD = TextBox35.Value
PartSum = GA + GB + GC + GD
Dim NamingArray() As String
ReDim NamingArray(1 To PartSum)
For i = 0 To GA
NamingArray(i) = "GA " & CStr(i)
Next i
For j = GA To GA + GB
NamingArray(i) = "GB " & CStr(j)
Next j
For k = GA + GB To GA + GB + GC
NamingArray(i) = "GC " & CStr(k)
Next k
For l = GA + GB + GC To GA + GB + GC + GD
NamingArray(i) = "GD " & CStr(l)
Next l
'check entries
For i = LBound(NamingArray) To UBound(NamingArray)
MsgBox (NamingArray(i))
Next i
你能後失敗的代碼? – jonsca 2011-06-17 08:47:34