我有一个从A列到F列的动态长度列表。(从第1行开始)我需要创建一个代码,以便在弹出窗口中打印此列表。我不希望它打印在另一张纸上,此列表所在的纸张非常隐藏。我需要尽量减少复制这些数字,这就是为什么我不希望它在另一张纸上。
问题就像我说的这个列表是动态长度。所以我有类似的东西:
msgbox(upf.cells(1,1) & " " & upf.cells(1,2) & " " & upf.cells(1,3) & " " & upf.cells(1,4) _
upf.cells(2,1) & " " & upf.cells(2,2) & " " & upf.cells(2,3) & " " & upf.cells(2,4) _
... up to row lr)
如何在某种类型的i = 1到lr循环中写这个?
谢谢!
答案 0 :(得分:0)
作为一个基本的例子......
Sub tgr()
Dim upf As Range
Dim cIndex As Long
Dim rIndex As Long
Dim sMsg As String
Set upf = Range("A1", Cells(Rows.Count, "F").End(xlUp))
For rIndex = 1 To upf.Rows.Count
For cIndex = 1 To upf.Columns.Count
sMsg = sMsg & " " & upf.Cells(rIndex, cIndex)
Next cIndex
Next rIndex
MsgBox Mid(sMsg, 2)
End Sub