vba替换\\

Sub RemoveTextBetweenSlashes()
    Dim rng As Range
    Dim cell As Range
    '这里假设要处理的是当前活动工作表中已使用的单元格区域,你可以修改为特定的单元格范围
    Set rng = ActiveSheet.UsedRange
    For Each cell In rng
        Dim text As String
        text = cell.Value
        Dim startSlash As Long, endSlash As Long
        startSlash = InStr(text, "/")
        Do While startSlash > 0
            endSlash = InStr(startSlash + 1, text, "/")
            If endSlash > 0 Then
                text = Left(text, startSlash - 1) &"|"& Mid(text, endSlash + 1)
                startSlash = InStr(text, "/")
            Else
                startSlash = 0
            End If
        Loop
        cell.Value = text
    Next cell
End Sub

 

posted on 2024-11-05 21:48  隨風.NET  阅读(2)  评论(0编辑  收藏  举报

导航