如何处理宏中的通配符? [英] How to handle wild characters in Macros?

查看:78
本文介绍了如何处理宏中的通配符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了一段代码来替换任何字符,但是用 * 不能正常工作.可以指导我如何处理 * .
这是代码:

I have wrote a piece of code to replace any characters, but it doesn't work fine with *. Can some one guide how I can handle *.
Here is the code:

nextrow = ActiveCell.Row
tocolnbr = ActiveCell.Column
Columns(tocolnbr).Select

Selection.Replace What:="'", Replacement:="", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False

推荐答案

使用 根据Office支持的波浪符号.

Microsoft Excel使用波浪号(〜)作为标记来指示下一个字符是文字​​.使用查找和替换"对话框查找或替换代字号(〜),星号(*)或问号(?)之类的字符时,必须在找到什么盒子.

Microsoft Excel uses the tilde (~) as a marker to indicate that the next character is a literal. When you use the Find and Replace dialog box to find or replace a character such as a tilde (~), an asterisk (*), or a question mark (?), you must add a tilde (~) before the character in the Find what box.

所以它一定是这样的:

Selection.Replace What:="~*", Replacement:="", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False

这篇关于如何处理宏中的通配符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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