- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
12#
發表於 2015-9-17 05:38
| 只看該作者
回復 10# lpk187
可用自動填滿,試試- Sub Worksheet_Change(ByVal Target As Range)
- Dim i As Integer
- If Target.Address = "$B$2" Then
- Application.EnableEvents = False
- Cells(2, "A") = 1
- i = Application.InputBox("How many numbers you want to add?", "Prompt", , , , , , 1)
- With Range("A2:B2")
- Range(.Cells.Offset(1), .Cells.End(xlDown)) = "" '清除舊有資料
- .AutoFill Range("A2:B2").Resize(i) '自動填滿
- End With
- Application.EnableEvents = True
- End If
- End Sub
複製代碼 |
|