Insert Method

Applies To

Characters Object, Pictures Collection, Range Object.

Description

Syntax 1 (Range object): Inserts a cell or a range of cells into the worksheet or macro sheet and shifts other cells away to make space.

Syntax 2 (Characters object): Inserts a string before the selected characters.

Syntax 3 (Pictures object): Inserts the specified file as a picture.

Syntax 1

object.Insert(shift)

Syntax 2

object.Insert(string)

Syntax 3

object.Insert(filename, converter)

object

Required. Insert cells at this range (Syntax 1) or insert string before this character (Syntax 2).

shift

Optional. Specifies which way to shift the cells, either xlToRight or xlDown. If omitted, a default is used based on the shape of the range.

string

Required. The string to insert.

filename

Required. Specifies the file to insert.

converter

Required. Specifies the picture converter to use when loading the file. Can be one of xlBMP, xlWMF, xlPLT, xlCGM, xlHGL, xlPIC, xlEPS, xlDRW, xlTIF, xlWPG, xlDXF, xlPCX, or xlPCT.

Example

This example inserts a new row before row four on Sheet1.


Worksheets("Sheet1").Rows(4).Insert

This example inserts new cells at the range A1:C5 on Sheet1 and shifts cells down.


Worksheets("Sheet1").Range("A1:C5").Insert shift:=xlDown

This example inserts a new row at the active cell. The example must be run from a worksheet.


ActiveCell.EntireRow.Insert

This example replaces the first three characters in text box one on Sheet1 with the string "New" formatted as bold.


With Worksheets("Sheet1").TextBoxes(1).Characters(1, 3)
    .Insert "New"
    .Font.Bold = True
End With

This example adds the string "Done" to the end of text box one on Sheet1 by inserting the new string after the last character in the text box.


With Worksheets("Sheet1").TextBoxes(1)
    .Characters(.Characters.Count + 1).Insert String:="Done"
End With