XLA Routines: EE_AddTableCalculatedColumn

Nick's picture
Advanced function for adding a calculated col to a table
Sub EE_AddTableCalculatedColumn(Header As String, Formula As String)
'http://excelexperts.com/xla-routines-eeAddTableCalculatedColumn    for updates on this sub routine
' adds a calculated column to a table on the activesheet
Dim HeaderCol As Long
Dim myData  As Range
    If Cells(1).CurrentRegion.Rows.Count = 1 Then Exit Sub ' no data
    Set myData = EE_TableGetColumnData(Header)
    HeaderCol = EE_TableHeadingCol(Header)
    Cells(2, HeaderCol) = Formula
    myData.value = myData.value
End Sub