DefaultValue Property

Microsoft Excel Visual Basic

Show All Show All

DefaultValue Property

Returns Variant representing the default data type value for a new row in a column. The Nothing object is returned when the schema does not specify a default value. Read-only Variant.

This property is used only for lists linked to a Microsoft Windows SharePoint Services site.

expression.DefaultValue

expression    Required. An expression that returns a ListDataFormat object.

Remarks

In Excel, you cannot set any of the properties associated with the ListDataFormat object. You can set these properties, however, by modifying the list on the SharePoint site.

Example

The following example displays the setting of the DefaultValue property for the third column of the list in Sheet1 of the active workbook. This code requires a list linked to a SharePoint site.

    Sub ShowDefaultSetting()
    Dim wrksht As Worksheet
    Dim objListCol As ListColumn
   
    Set wrksht = ActiveWorkbook.Worksheets("Sheet1")
    Set objListCol = wrksht.ListObjects(1).ListColumns(3)

    If IsNull(objListCol.ListDataFormat.DefaultValue) Then
        MsgBox "No default value specified."
    Else
        MsgBox objListCol.ListDataFormat.DefaultValue
    End If
End Sub