這裏的另一種方式,你可以這樣做:
Sub Message_Box2()
Dim a As Range
Dim sTxt As String
Dim myData() As Variant
Dim numCols As Long, numRows As Long
With Sheets("Sheet1")
numCols = .Cells(1, .Columns.Count).End(xlToLeft).Column
numRows = .Cells(.Rows.Count, 1).End(xlUp).Row
ReDim myData(numCols, numRows)
myData() = Range("A1:C" & numRows)
End With
Dim i As Long, k As Long, numTimes As Long
For k = 1 To numCols
For i = 1 To numRows
sTxt = sTxt & vbLf & myData(i, k)
Debug.Print sTxt
Next i
MsgBox sTxt
sTxt = ""
Next k
End Sub
編輯:這是一個有點矯枉過正,但我只是想知道有一個可以使用一個數組來完成它,所以在我意識到它已經被回答之前就已經做好了。
目前,您擁有的代碼確實能夠正確顯示A列,對嗎?爲什麼不只是添加兩個循環? – BruceWayne
使用帶3列表框的用戶表單會更好嗎?或者只有一個列表框3列? –
現在工作正常。感謝大家。 –