ListDataFormat Object (Excel)

The ListDataFormat object holds all the data type properties of the ListColumn object. These properties are read-only.

Use the ListDataFormat property of the ListColumn object to return a ListDataFormat object. The default property of the ListDataFormat object is the 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 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 
 

Community Additions

ADD
Show:
© 2014 Microsoft