- 帖子
- 39
- 主題
- 15
- 精華
- 0
- 積分
- 69
- 點名
- 0
- 作業系統
- Windows 7
- 軟體版本
- office 2016
- 閱讀權限
- 20
- 性別
- 男
- 來自
- 新北市
- 註冊時間
- 2018-11-23
- 最後登錄
- 2020-2-26
 
|
3#
發表於 2019-2-20 13:50
| 只看該作者
回復 2# Hsieh
誤會我的意思了 謝謝 已用這個方法解決
Private Sub CommandButton1_Click()
If TextBox1.Value = "" Or Cells(1, 1) = "" Then Exit Sub
If IsNumeric(Cells(1, 1)) Then
For i = 2 To TextBox1.Value
Cells(i, 1) = Cells(i - 1, 1) + 1
Next
Else
Set reg = CreateObject("vbscript.regexp")
With reg
.Global = True
.Pattern = "[0-9]"
For Each Match In .Execute(Cells(1, 1))
numb = numb & Match
Next
End With
eng = Left(Cells(1, 1), Len(Cells(1, 1)) - Len(numb))
For i = 2 To TextBox1.Value
Cells(i, 1) = eng & (numb + i - 1)
Next
'[a1].AutoFill Destination:=Range("a1:a" & TextBox1.Value + 1), Type:=xlfillserise
End If
End Sub
Private Sub CommandButton2_Click()
Columns(1).ClearContents
End Sub |
|