- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 142
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2026-7-16
                
|
回復 1# av8d
假設資料在A欄
工作表模組- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- Application.EnableEvents = False
- If Target.Count = 1 Then
- If Target.Column = 1 Then
- ReDim Preserve Ar(s)
- Ar(s) = Target.Value
- s = s + 1
- [B65536].End(xlUp).Offset(1) = Target
- Target.Delete xlShiftUp
- End If
- End If
- Application.EnableEvents = True
- End Sub
複製代碼 一般模組- Public Ar(), s&
- Sub 按鈕1_Click()
- If s = 0 Then Exit Sub
- Application.EnableEvents = False
- [A1].Resize(s, 1).Insert xlShiftDown
- [A1].Resize(s, 1).Value = Application.Transpose(Ar)
- Range([B2], [B2].End(xlDown)).ClearContents
- s = 0: Erase Ar: Set Rng = Nothing
- Application.EnableEvents = True
- End Sub
複製代碼
|
|