Kenja824
Automotive
- Nov 5, 2014
- 950
I have this piece of code. It adds a column at the end of the table and places a formula into it. The formulas are functions we created in the code file. They simply extract certain info from the text string. The problem I am having, is there are two different columns this info could be in and if its not in the one column it needs to extract it from the second column. The formula not commented out (in red) below works if I enter it into the cell manually, but for some reason it gets an error when I run my file.
With ActiveSheet
If Not bHasListObject Then
'make active sheet table a Structured Table
' .ListObjects.Add(xlSrcRange, .UsedRange, , xlYes).Name = "Table" & iCnt + 1
With .Cells(1, 1).End(xlToRight)
'put formula in a new table column to the far right
.Offset(0, 1).Value = "RO#"
' .Offset(2, 1).Formula = "=if(XtractR01([@Number])="",XtractR01([@[Rob '#]]),XtractR01([@Number]))"
.Offset(2, 1).Formula = "=IF(XtractR01([@Number])="",XtractR01([@[ROB '#]]),XtractR01([@Number]))"
End With
End If
End With
I will check tomorrow for answers. Thanks
With ActiveSheet
If Not bHasListObject Then
'make active sheet table a Structured Table
' .ListObjects.Add(xlSrcRange, .UsedRange, , xlYes).Name = "Table" & iCnt + 1
With .Cells(1, 1).End(xlToRight)
'put formula in a new table column to the far right
.Offset(0, 1).Value = "RO#"
' .Offset(2, 1).Formula = "=if(XtractR01([@Number])="",XtractR01([@[Rob '#]]),XtractR01([@Number]))"
.Offset(2, 1).Formula = "=IF(XtractR01([@Number])="",XtractR01([@[ROB '#]]),XtractR01([@Number]))"
End With
End If
End With
I will check tomorrow for answers. Thanks