xlSet

This function puts constant values into cells or ranges very quickly.

If successful, returns TRUE (xltypeBool). If unsuccessful, returns FALSE.

Syntax

Excel4(xlSet, LPXLOPER pxRes, 2, LPXLOPER pxReference,
LPXLOPER pxValue);

pxReference (xltypeRef or xltypeSRef)

A rectangular reference describing the target cell or cells. The reference must describe adjacent cells.

pxValue

The value to put in the cell or cells. For more information, see the following "Remarks" section.

Remarks

pxValue Argument

pxValue can either be a value or an array. If it is a value, the entire destination range is filled with that value. If it is an array (xltypeMulti), the elements of the array are put into the corresponding locations in the rectangle.

If you use a horizontal array for the second argument, it is duplicated down to fill the entire rectangle. If you use a vertical array, it is duplicated right to fill the entire rectangle. If you use a rectangular array, and it is too small for the rectangular range you want to put it in, that range is padded with #N/As.

To clear an element of the destination rectangle, use an xltypeNil XLOPER in the source array. To clear the entire destination rectangle, omit the second argument.

Restrictions

xlSet cannot be undone. In addition, it destroys any undo information that may have been available before.

xlSet can put only constants, not formulas, into cells.

xlSet behaves as a Class 3 command-equivalent function; that is, it is available only inside a DLL when the DLL is called from an object, macro, menu, toolbar, shortcut key, or the Run button in the Macro dialog box (accessed from the Tools menu).

Example

The following example fills B205:B206 with the value that was passed in from a macro.

\SAMPLES\EXAMPLE\EXAMPLE.C

short WINAPI xlSetExample(short int iVal)
{
    XLOPER xRef, xValue;

    xRef.xltype = xltypeSRef;
    xRef.val.sref.count = 1;
    xRef.val.sref.ref.rwFirst = 204;
    xRef.val.sref.ref.rwLast = 205;
    xRef.val.sref.ref.colFirst = 1;
    xRef.val.sref.ref.colLast = 1;
    xValue.xltype = xltypeInt;
    xValue.val.w = iVal;
    
    Excel4(xlSet, 0, 2, (LPXLOPER)&xRef, (LPXLOPER)&xValue);
    return 1;
}

Related Function

xlCoerce