Skip to content

Latest commit

 

History

History
53 lines (34 loc) · 1.32 KB

Excel.ControlFormat.AddItem.md

File metadata and controls

53 lines (34 loc) · 1.32 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
ControlFormat.AddItem method (Excel)
vbaxl10.chm630073
vbaxl10.chm630073
Excel.ControlFormat.AddItem
fffc243b-3f94-14ab-f7b4-83c56325aa5e
04/23/2019
medium

ControlFormat.AddItem method (Excel)

Adds an item to a list box or a combo box.

Syntax

expression.AddItem (Text, Index)

expression A variable that represents a ControlFormat object.

Parameters

Name Required/Optional Data type Description
Text Required String The text to be added.
Index Optional Variant The position of the new entry. If the list has fewer entries than the specified index, blank items from the end of the list are added to the specified position. If this argument is omitted, the item is appended to the existing list.

Remarks

Using this method clears any range specified by the ListFillRange property.

Example

This example creates a list box and fills it with integers from 1 to 10.

With Worksheets(1) 
 Set lb = .Shapes.AddFormControl(xlListBox, 100, 10, 100, 100) 
 For x = 1 To 10 
 lb.ControlFormat.AddItem x 
 Next 
End With

[!includeSupport and feedback]