SearchForMerged |
This page in 2003 Top Previous Next |
|
Searches a specified area of a worksheet for cells that have been merged, selecting any that are found in a multi-area range. Applies to SYNTAX result1 = expression1.SearchForMerged Set result2 = expression2.SearchForMerged(Range1) expression1 Required. An expression that returns an IOAKAddIn object. expression2 Required. An expression that returns an IOAKAPI object. result1 An OAKResult enumeration indicating the success or otherwise of the action. result2 Range containing of all the merged cells found within Range1, or Nothing if no such cells are found. Range1 Required Range. The range in which to search for merged cells. Remarks When applied to an IOAKAddIn object, the SearchForMerged method performs the same action as the OAK Development | Search | Merged cells command. It searches for merged cells within the current selection. When applied to an IOAKAPI object, the SearchForMerged method applies searches for merged cells within the range indicated by the parameter submitted to the method. Wrinkles When applied to an IOAKAddIn object, the SearchForMerged method follows the One-cell rule. When applied to an IOAKAPI object, it does not: if supplied a Range parameter describing a single cell, it will look in that cell only. When applied to an IOAKAddIn object, the method will display a dialog box if zero or one area of merged cells is detected, just as the equivalent OAK user-interface command does. Example This code fragment identifies any merged cells in the active worksheet and replaces the merge with the more desirable Center across selection formatting. Option Explicit Sub Main() Dim o As Operis_OAK.IOAKAPI, r As Range Set o = CreateObject("Operis.OAK.Connect") Set o.ExcelApplication = Application
Set r = o.SearchForMerged(ActiveSheet.Cells) If r is Nothing then Exit Sub r.UnMerge r.HorizontalAlignment = xlCenterAcrossSelection End Sub |