回覆列表
  • 1 # 羽諾池唯

    問題1:Sub 取數字()Set lk = CreateObject("vbscript.regexp")lk.Global = Truelk.Pattern = "[0-9]{1,}"For Each Ln In Range("a1", Cells(Rows.Count, "a").End(xlUp).Address)For Each lp In lk.Execute(Ln)Cells(Ln.Row, "c") = lp.ValueNextNextEnd Sub問題2:Sub 取數字()n = InputBox("請輸入需要提取第多少次出現的數字字串", "提示", vbOKOnly)If VBA.IsNumeric(n) = False ThenMsgBox "輸入的不是數字", vbInformation, "錯誤提示"Exit SubEnd IfSet lk = CreateObject("vbscript.regexp")lk.Global = Truelk.Pattern = "[0-9]{1,}"For Each Ln In Range("a1", Cells(Rows.Count, "a").End(xlUp).Address)For Each lp In lk.Execute(Ln)k = k + 1If k = CInt(n) ThenCells(Ln.Row, "c") = lp.ValueExit SubEnd IfNextNextEnd Sub

  • 中秋節和大豐收的關聯?
  • 刷刷醬的做法?