专题推荐
最新评论
站点统计
  • 文章 7
  • 标签 13
  • 分类 8
  • 运营 1366 天
excel中将"C"列中中英文括号内的任意字符一键清除
soft997 2024-07-23 45
Sub RemoveBrackets()
    Dim ws As Worksheet
    Dim rng As Range
    Dim cell As Range
    Dim cellValue As String
    Dim i As Integer
    
    ' 指定工作表
    Set ws = ThisWorkbook.Sheets("Sheet1") ' 修改 "Sheet1" 为你工作表的名字
    
    ' 指定范围 (C 列)
    Set rng = ws.Range("C1:C" & ws.Cells(ws.Rows.Count, "C").End(xlUp).Row)
    
    ' 遍历范围内的每个单元格
    For Each cell In rng
        cellValue = cell.Value
        
        ' 删除中英文括号及其内容
        Do While instr(cellValue, "(") > 0 Or InStr(cellValue, "(") > 0
            i = InStr(cellValue, "(")
            If i > 0 Then
                cellValue = Left(cellValue, i - 1) & Mid(cellValue, InStr(i, cellValue, ")") + 1)
            End If
            
            i = InStr(cellValue, "(")
            If i > 0 Then
                cellValue = Left(cellValue, i - 1) & Mid(cellValue, InStr(i, cellValue, ")") + 1)
            End If
        Loop
        
        cell.Value = cellValue
    Next cell
End Sub

Alt+F11 插入新模块,保存以上代码后退出。
Alt+F8 选中模块执行

Comments | 0 条评论

*昵称必须填写

评论头像 点击填写昵称和邮箱,方可发布评论
空空如也!
23202407https://www.soft997.com/zb_users/theme/Moments/images/2.pngexcel中将"C"列中中英文括号内的任意字符一键清除Sub RemoveBrackets() Dim.....https://www.soft997.com/zb_users/theme/Moments/plugin/img/poster_okclose.pnghttps://www.soft997.com/zb_users/theme/Moments/plugin/api.php?url=https://www.soft997.com/zb_users/theme/Moments/plugin/img/poster_zw.png咸鱼标
联系客服

客服QQ

客服微信