ListDataFormat Object [Excel 2003 VBA Language Reference]


The ListDataFormat object holds all the data type properties of the

Visit ListColumn

object. These properties are read-only.

Using the ListDataFormat Object

Use the ListDataFormat property of the ListColumn object to return a ListDataFormat object collection. The default property of the ListDataFormat object is the

Visit Type

property which indicates the data type of the list column. This allows the user to write code without specifying the Type property.

The following code example creates a linked list from a SharePoint list. It then checks to see if field 2 is required (field 1 is the ID field, which is read only). If it's a required text field, the same data is written in all existing records.

Note  The following code example assumes that you will substitute a valid server name and the list guid in the variables strServerName and strListGuid. Additionally, the server name must be followed by "/_vti_bin" or the sample will not work.

Dim objListObject As ListObject
Dim objDataRange As Range
Dim strListGUID as String
Dim strServerName as String

strServerName = "http://<servername>/_vti_bin"
strListGUID = "{<listguid>}"

Set objListObject = Sheet1.ListObjects.Add(xlSrcExternal, _
    Array(strServerName, strListGUID), True, xlYes, Range("A1"))

With objListObject.ListColumns(2)
    Set objDataRange = .Range.Offset(1, 0).Resize(.Range.Rows.Count - 2, 1)
    If .ListDataFormat.Type = xlListDataTypeText And .ListDataFormat.Required Then
        objDataRange.Value = "Hello World"
    End If
End With

Properties | AllowFillIn Property | Application Property | Choices Property | Creator Property | DecimalPlaces Property | DefaultValue Property | IsPercent Property | LCID Property | MaxCharacters Property | MaxNumber Property | MinNumber Property | Parent Property | ReadOnly Property | Required Property | Type Property

Parent Objects | ListColumn Object

Child Objects

See Also | Publish Method