美文网首页
6.VBA批量替换

6.VBA批量替换

作者: Ly3911 | 来源:发表于2022-12-15 10:59 被阅读0次

    Sub Replace2()

    Dim XX, a

    Worksheets(1).Activate
    a = Excel.Application.WorksheetFunction.CountA(Range("A:A"))

    For j = 2 To Worksheets.Count

    With .Worksheets(j).Activate
    For i = 1 To a
    XX = Worksheets(1).Range("A" & i).Value
    Debug.Print XX
    Range("Q:Q,P:P").Select
    Selection.Replace What:=XX, Replacement:="", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
    Next

    Range("Q:Q,P:P").Select
    Selection.Replace What:=";;", Replacement:=";", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
    

    Next
    End Sub

    相关文章

      网友评论

          本文标题:6.VBA批量替换

          本文链接:https://www.haomeiwen.com/subject/yohuvrtx.html