我在单元格中有这样的格式:
S: 7
P:
M: 1
L:1
K: 1
Q: 7
我想提取每个数字并将其写在另一列中,例如 forS: 7 我想在 coumn BC 中写 7,对于 P:0,在 BD 中写 0 和...(数字和 : 之间的空格是灵活的)我怎么能用vba做到这一点?
更新:
Dim objRegex As Object
Dim objRegMC As Object
Dim objRegM As Object
Dim lngCnt As Long
usedRowCount = Worksheets("Übersicht_2013").UsedRange.Rows.Count
For i = 1 To usedRowCount
cellAYvalue = Worksheets("Übersicht_2013").Cells(i, "AY").Value
cellAYvalue = Replace(cellAYvalue, " ", "")
Set objRegex = CreateObject("vbscript.regexp")
With objRegex
.Pattern = "[A-Z]:\s?(\d?)"
.Global = True
If .test(cellAYvalue) Then
Set objRegMC = .Execute(cellAYvalue)
For Each objRegM In objRegMC
'[bc1].Offset(0, lngCnt) = objRegM.submatches(0)
Worksheets("Übersicht_2013").Cells(i, "BC") = objRegM.submatches(0)
lngCnt = lngCnt + 1
Next
End If
End With
Next i
谢谢