SetCells

Sets data for an array of cells. For each cell in the array, you can either insert data or set the cell to Null.

Note:

If any of the specified cells are not writable, SetCells fails. For a similar method that does not fail when non-writable cells are encountered, use SetCells2. SetCells also returns the statuses of the cells.

SetCells takes arrays of dimension member IDs as arguments, as well as an array of data for the cells to be set. These arrays must contain identical numbers of elements. The elements of the member ID arrays have a one-to-one correspondence to the elements of the data array.

Tip:

SetCells passes the cells’ data in a Double array. To insert data into cells by passing a String array, use SetTextCells instead of SetCells. For more information, see SetTextCells.

Syntax

<HsvData>.SetCells varalScenario, varalYear, varalPeriod, varalView, varalEntity, varalParent, varalValue, varalAccount, varalICP, varalCustom1, varalCustom2, varalCustom3, varalCustom4, varadData, varabIsNoData

Argument

Description

varalScenario

Long array (ByVal). The member IDs of the cells' Scenario dimension members.

varalYear

Long array (ByVal). The member IDs of the cells' Year dimension members.

varalPeriod

Long array (ByVal). The member IDs of the cells' Period dimension members.

varalView

Long array (ByVal). The member IDs of the cells' View dimension members.

varalEntity

Long array (ByVal). The member IDs of the cells' Entity dimension members.

varalParent

Long array (ByVal). The member IDs of the parents of the varalEntity argument's entities.

varalValue

Long array (ByVal). The member IDs of the cells' Value dimension members.

varalAccount

Long array (ByVal). The member IDs of the cells' Account dimension members.

varalICP

Long array (ByVal). The member IDs of the cells' Intercompany Partner dimension members.

varalCustom1

Long array (ByVal). The member IDs of the cells' Custom 1 dimension members.

varalCustom2

Long array (ByVal). The member IDs of the cells' Custom 2 dimension members.

varalCustom3

Long array (ByVal). The member IDs of the cells' Custom 3 dimension members.

varalCustom4

Long array (ByVal). The member IDs of the cells' Custom 4 dimension members.

varadData

Double array (ByVal). The data to be inserted in the cells. The elements in this array correspond to the elements in the other arguments. For example, the fifth element in this array is inserted in the cell defined by the member IDs in the fifth elements of the other arguments’ arrays.

varabIsNoData

Boolean array (ByVal). Determines whether the corresponding element in the varadData argument’s array is inserted or the cell is set to Null. Pass FALSE to insert data, TRUE to set a cell to Null.

You might find it useful to conditionally pass TRUE in cases where a varadData element is 0 (zero).

Caution!

Passing TRUE deletes any existing data in a cell.

Example

The following subroutine inserts data into cells; if 0 is passed for a cell’s data, the cell is set to Null. The cells’ dimension members and data are passed in the subroutine’s arguments. The subroutine constructs the array passed to SetCells’ varabIsNoData argument; if 0 is passed for a cell’s data, the corresponding item in the baNull array is set to TRUE.

Sub setCellsOrNull(laScen() As Long, laYear() As _
    Long, laPer() As Long, laView() As Long, laEnt() As Long, _
    laPar() As Long, laVal() As Long, laAcct() As Long, laICP() _
    As Long, laCust1() As Long, laCust2() As Long, laCust3() _
    As Long, laCust4() As Long, daData() As Double)
Dim cData As HsvData, baNull() As Boolean
'g_cSession is an HsvSession object reference
Set cData = g_cSession.Data
'Build the baNull array
ReDim baNull(UBound(daData))
For i = LBound(daData) To UBound(daData)
    If daData(i) = 0 Then
        baNull(i) = True
    Else
        baNull(i) = False
    End If
Next i
cData.SetCells laScen, laYear, laPer, laView, laEnt, _
    laPar, laVal, laAcct, laICP, laCust1, laCust2, laCust3, _
    laCust4, daData, baNull
End Sub