真的在这里挣扎! 我想用新值替换每个提取的数字。 目前,我的代码仅替换分隔符之前的第一个分组编号,但它不会返回到同一个单元格,以便对其他数字执行相同的操作。
我希望每个持有者不要进入另一个单元格,而是要更换值。 这是我的代码
enter code here
Sub match2()
Dim count As Long, count1 As Long
Dim holder As String, SNL_ID As String
Dim sample As String, smallSample As String, S_doc As String, a_label As String, m_label As String
Dim LastRowa As Long, mrow As Long, x As Long, Arow As Long, v As Long, srow As Long, y As Long, SNL_val As String
Dim Speriod As Date
'If AG mappping label = AG label then copy and paste results in column A
mrow = Sheet1.Cells(Rows.count, "A").End(xlUp).Row
For x = 2 To mrow
m_label = Sheet1.Cells(x, "C").Value
S_doc = "FRY-9C"
Arow = Sheet2.Cells(Rows.count, "A").End(xlUp).Row
For v = 2 To Arow
a_label = Sheet2.Cells(v, "N").Value
srow = Sheet3.Cells(Rows.count, "A").End(xlUp).Row
For y = 2 To srow
SNL_ID = Sheet3.Cells(y, "H").Value
SNL_val = Sheet3.Cells(y, "H").Value
If a_label = m_label & Worksheets("Mapping").Range(x, "M").Value = S_doc Then
Worksheets("Mappings").Activate
Worksheets("Mappings").Cells(x, 10).copy
Worksheets("AG").Select
Worksheets("AG").Cells(v, "A").PasteSpecial
Application.CutCopyMode = False
End If
Next y
Next v
Next x
count = 0
LastRowa = Worksheets("Match2").Cells(Rows.count, "A").End(xlUp).Row
With Sheet4
For i = 1 To LastRowa
count1 = 3
holder = ""
sample = Worksheets("Match2").Range("C" & i).Value
Do While count <> Len(sample)
smallSample = Left(sample, 1)
If smallSample = "0" Or smallSample = "1" Or smallSample = "2" Or smallSample = "3" Or smallSample = "4" Or smallSample = "5" Or smallSample = "6" Or smallSample = "7" Or smallSample = "8" Or smallSample = "9" Then
holder = holder & smallSample
If InStr(holder, SNL_ID) > 0 Then
holder = holder & SNL_val
Else
If holder <> "" Then
'Cells(i, count1) = holder
count1 = holder + 1
End If
holder = ""
End If
End If
'If Len(sample) = 1 Then Cells(i, count1) = holder
'sample = (Right(sample, Len(sample) - 1))
Loop
Next i
End With
End Sub