在Excel中查找和删除数据列中的某些字符 [英] Finding and removing some characters in a column of data in Excel

查看:79
本文介绍了在Excel中查找和删除数据列中的某些字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将一些调试信息复制并粘贴到Excel工作表中。

I have copied and pasted some debugging information into an Excel sheet.

但是,它在一列的某些单元格中包含一些怪异字符,否则应仅包含整数。使用VBA消除此类字符的最简单方法是什么?下面的列表中显示了一个示例:

However, it contains some "weird" characters in some cells of one column, that should otherwise contain integers only. What would be the easiest way to eliminate such characters using VBA? An example is shown in the list below:

1 **'␁'** <- I'm trying to get rid of the part that I have bolded
2 '␂'
3 '␃'
4 '␂'

我想将该文件用作另一个应用程序中的数据源。

I want to use the file as a data source in another application. Thanks in advance.

推荐答案

这对我有用,尽管它可能不是很优雅:

Here's a solution that worked for me, although it may not be very elegant:

Sub Macro1()
    ' Macro1 Macro
    Dim temp As String

    For u = 1 To 28000
        If Cells(u, 4) <> 0 Then
            Cells(u, 4).Select
            temp = Mid(ActiveCell.Text, 1, InStr(1, ActiveCell.Text, "'") - 1)
            Cells(u, 4) = temp
        End If
    Next
End Sub

这篇关于在Excel中查找和删除数据列中的某些字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆