- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
回復 4# die78325
試試看- Option Explicit
- Sub Ex()
- Dim Ar(), 字串 As String, xi As Integer, xii As Integer, S As String, Rng As Range
- 'With Range("A1").CurrentRegion
- 'CurrentRegion 屬性 傳回 Range 物件,該物件代表目前的區域。目前區域是指以任意空白列及空白欄的組合為邊界的範圍。唯讀
- 'MsgBox .Address
- Set Rng = Sheet1.[a1]
- With Sheet1.Range(Rng.Address, Cells(Rng.End(xlDown).Row, Rng.End(xlToRight).Column).Address)
- MsgBox .Address(, , , 1, 1)
- Ar = .Value
- For xi = 1 To .Rows.Count
- For xii = 1 To .Columns.Count
- Ar(xi, xii) = IIf(.Cells(xi, xii) <> "", .Cells(xi, xii).Text, vbTab)
- Next
- Next
- For xi = 1 To UBound(Ar)
- S = Join(Application.Transpose(Application.Transpose(Application.Index(Ar, xi))), vbTab)
- 字串 = IIf(字串 = "", S & vbLf, 字串 & vbLf & S)
- Next
- MsgBox 字串
- End With
- ' '
- '
-
- ' With .Document
- ' .getElementsByName("q11")(0).Value = 字串 ' 找到q11欄位填入
- 'End With
- End Sub
複製代碼 |
|