XLA routines: EE_InsertColumns

Nick's picture
EE_InsertColumns inserts columns
Sub EE_InsertColumns(FromCol As Variant, Optional ToCol As Variant)
' - FromCol and ToCol can either be a column, a letter, a number, or a heading
'http://excelexperts.com/xla-routines-eeInsertColumns    for updates on this routine

    If Not IsMissing(ToCol) Then
        If ToCol = "" Then
            ToCol = FromCol
        End If
    Else
        ToCol = FromCol
    End If
 
    If VarType(ToCol) = vbString Then
        ToCol = CLng(range(ToCol & "1").Column)
    End If
    If VarType(FromCol) = vbString Then
        FromCol = CLng(range(FromCol & "1").Column)
    End If
 
    Dim i As Long
    For i = FromCol To ToCol
        Columns(i).Insert
    Next
End Sub