Sub Get_number_in_string()
Dim regex As Object
Dim inputRange As Range
Dim cell As Range
Dim outputString As String
' Initialize regular expression object
Set regex = CreateObject("VBScript.RegExp")
' Set the pattern to match numbers (\d+)
regex.Pattern = "(\d{1,3},)*\d{3}"
' Select the range of cells
Set inputRange = Selection ' Assumes you have already selected the desired range
' Loop through each cell in the selected range
For Each cell In inputRange
' Extract numbers from the cell value
If regex.test(cell.Value) Then
Dim matches As Object
Set matches = regex.Execute(cell.Value)
' Concatenate all matched numbers
Dim i As Integer
For i = 0 To matches.Count - 1
outputString = matches.Item(i).Value
Next i
End If
cell = outputString
Next cell
End Sub
'파이썬+VBA' 카테고리의 다른 글
엑셀에서 파이썬사용하기(xlwings) (0) | 2023.08.11 |
---|---|
빈칸끌어올리기VBA (0) | 2023.06.19 |
엑셀 VBA 크롤링 (0) | 2023.06.08 |
파이썬 새로 설치시 (0) | 2023.05.11 |
import win32com.client (0) | 2023.05.03 |