Special characters
The special codes in the Find What and Replace With boxes depends on which type of match is being used.
Searching in Cells
Microsoft Excel provides the following special 'wildcard' characters.
Use | To find |
---|---|
? (question mark) | Any single character For example, sm?th finds "smith" and "smyth" |
* (asterisk) | Any number of characters For example, *east finds "Northeast" and "Southeast" |
~ (tilde) followed by ?, *, or ~ | A question mark, asterisk, or tilde For example, fy91~? finds "fy91?" |
Microsoft Excel uses the tilde (~) as a marker to indicate that the next character is a literal. When you click Find or Replace on the Edit menu to replace or search for a tilde (~), an asterisk (*), or a question mark (?), you must precede the character with a tilde (~).
NOTE: If you want to find or replace a tilde in your worksheet, you must type a double tilde (~~).
Example 1: How to Find and Replace NumbersTo replace wildcard characters (*) in a numeric value in a worksheet cell, use the steps in the following example:
NOTE:
|
Example 2: How to Find and Replace a TildeTo replace a tilde in an Excel worksheet cell, use the steps in the following example:
|
Searching in Links and other 'Hidden' Locations
You can specify one or more of the macros below to insert custom text in the Replace With field.
Macro Name | Description |
@inputFilename@ or @filename@ | Replaced by the name of the current file being processed. The drive and path section of the filename is removed. |
@fullInputFilename@ | Same as @inputFilename, except it includes the complete path |
@inputPath@ | The path to the input file, with a trailing slash e.g. 'c:\my files\' |
@inputExtension@ | The extension of the input file e.g. '.txt' |
@clipboard@ | Inserts the contents of the Windows clipboard |
@time@ | Inserts the time in the format HHMMSS |
@date@ | Inserts the date in the format YYYYMMDD |
@datetime@ | Inserts the date and time in the format YYYYMMDDHHMMSS |
@_year@ | Inserts the year in the format YYYY |
@_month@ | Inserts the month in the format MM |
@_day@ | Inserts the day in the format DD |
@_hour@ | Inserts the hour in the format HH |
@_minute@ | Inserts the minute in the format MM |
@_second@ | Inserts the second in the format SS |
@randomdigit@ | Inserts a random digit from 0-9. For two digits, use @randomdigit@@randomdigit |
@randomletter@ | Inserts a randomletter from A-Z. For two letters, use @randomletter@@randomletter |
@ENV_varname@ | Where varname is the name of an environment variable, this inserts the value of a environment variable e.g. @ENV_OS inserts the text 'Windows_NT' on an NT system. See below for 'what are environment variables' |
Special requirements | Replace With text: | With Macro Values | Results in: |
If you need to put an @ in the text, simply double it i.e. @@. | hello@@ | N/A | hello@ |
If you need to include the literal name of a macro, just double the @ | @@randomdigit | @randomdigit=7 | @randomdigit |
If you need to place letters or digits immediately after a macro name, end the macro name with @. | @randomdigit@@randomdigit | @randomdigit=7, @randomdigit=2 | 72 |
& | @randomdigit@@@ | @randomdigit=7 | 7@ |