vba 如何删除excel 2007中的空字符?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19738587/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove null characters in excel 2007?
提问by dixi
I have a data that has blank cells. However, this are not actually blank. If i used teh =isblank() function, it returns false.
我有一个包含空白单元格的数据。然而,这实际上并不是空白。如果我使用了 =isblank() 函数,它会返回 false。
I got this code from a website
我从一个网站上得到了这个代码
Sub NoNull()
Dim c As Range
For Each c In Selection
If c.Value = " " Then c.ClearContents
Next c
End Sub
As instructed, I highlight the column that I need to clear those blank cells. However, when i run it from the Visual Basic Editor (Excel 2007), im not seeing any effect. The cells still contain those null character. Note; I assume the character is " ". I am not really sure how to verify that.
按照指示,我突出显示我需要清除这些空白单元格的列。但是,当我从 Visual Basic 编辑器 (Excel 2007) 运行它时,我没有看到任何效果。单元格仍然包含那些空字符。笔记; 我假设字符是“”。我不确定如何验证这一点。
Dixi
迪西
Editted: The code above works. initially i dont have a space between c.Value = "spacehere". Thanks to gary's suggestion. I made it work.
编辑:上面的代码有效。最初我在 c.Value = "spacehere" 之间没有空格。感谢加里的建议。我让它工作。
采纳答案by dixi
Please see my editted post above. This has been resolved. There is a missing space between " and ".
请参阅上面我编辑过的帖子。这已得到解决。“和”之间缺少空格。
Should be c.Value = "spacehere"
应该是 c.Value = "spacehere"
The column needs to highlighted before you run the program. Might take a while if you have a large data set. I think this code only works for a single column at a time.
在运行程序之前需要突出显示该列。如果您有大量数据集,可能需要一段时间。我认为这段代码一次只适用于一列。
Thanks!
谢谢!
回答by Santosh
Select the cells and click on Clear (Under Editing Group )
选择单元格并单击清除(在编辑组下)