Select the product you need help with
XL: Macro to Search for Cell Formats: Font, Border, and InteriorArticle ID: 142122 - View products that this article applies to. This article was previously published under Q142122 On This PageSUMMARY
In Microsoft Excel, there is no built-in feature to allow you to search
on the characteristics of a cell. However, you can create a Microsoft
Visual Basic for Applications procedure that allows you to search this way.
MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
To create a sample Visual Basic macro that selects a range and searches it for specific formatting:
Note that although this macro displays message boxes to indicate the result of the code, you can customize this code to perform a variety of actions when the correct cells are located. Testing for Properties of the Font ObjectThe following tables describe properties of the Font object that you can test for in a Visual Basic macro.Properties That Return a Boolean Value (True Or False)
For this property True means this False means this
-------------------------------------------------------------
Bold Font is bold Font is not bold
Italic Font is italic Font is not italic
OutlineFont Font is outline Font is not outline Font
font
Shadow Font is shadow Font is not shadow Font
font
Strikethrough Font is Font is not formatted with
formatted with strike through
strike through
Subscript Font is Font is not subscript
subscript
Superscript Font is Font is not superscript
superscript
Properties That Return a String or Numeric Value
For this property Test for this value
------------------------------------------------------------------
Color The font color as an RGB value
ColorIndex The color as an index number from
the current color palette
FontStyle The font style as a string (for
example, "Bold")
Name The name for the font (for example, "Arial")
Size The size of the font (for example, 12)
Underline The type of underline applied to text in a
the cell (for example, "xlSingle")
Testing for Properties of the Border ObjectFor this property Test for this value ----------------------------------------------------------------- Color The border color as an RGB value ColorIndex The color as index of the current color palette Linestyle The line style (for example "xlContinuous") Weight The weight of the line (for example "xlHairline") Testing for Properties of the Interior ObjectThe Interior object is used to detect the color or pattern in the cell itself. You can test the Interior object for the following properties.For this property Test for this value --------------------------------------------------------------- Color The primary color ColorIndex The color as index of current color palette Pattern The pattern (for example, "xlChecker") PatternColor The pattern color as a RGB value PatternColorIndex The color as index of current color palette REFERENCES
In Microsoft Excel 7.0 and 97, to find more information about the Font object, the Border object, or the Interior object, click Answer Wizard on the Help menu and type the appropriate word:
Font Object
In Microsoft Excel 5.0, for more information about the Font object, the Border object, or the Interior object, choose the Search button in Visual Basic Help, and type the appropriate word:
-or- Border Object -or- Interior Object Font Object -or- Border Object -or- Interior Object PropertiesArticle ID: 142122 - Last Review: October 11, 2006 - Revision: 2.3 APPLIES TO
|



Back to the top








