Sub ExtractVisData()
Dim ws As Worksheet
Dim rng As Range, cell As Range
Dim lastRow As Long
Dim regex As Object
Dim matches As Object
Dim outputRow As Integer
' 搜尋 "Vis" 並擷取數字
For Each cell In ws.Range("A1:A" & lastRow) ' 假設資料在 A 欄
If InStr(1, cell.Value, "Vis", vbTextCompare) > 0 Then
' 使用正則表達式提取數字
Set matches = regex.Execute(cell.Value)
If matches.Count > 0 Then
ws.Cells(outputRow, 2).Value = matches(0) ' 儲存第一個找到的數字
outputRow = outputRow + 1
End If
End If
Next cell
' 清除物件
Set regex = Nothing
MsgBox "提取完成,請檢查 B 欄的結果!", vbInformation
End Sub