Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50123

Help Inserting formulas into cells

$
0
0
I have a vba macro in which I am appending columns to an already existing excel data sheet. I append these additional Columns as follows.

NOTE: I have intentionally changed the Column Names.

Code:

calculationColumns = Array("NewColumn1", "NewColumn2", "NewColumn3", "NewColumn4", "NewColumn5", "NewColumn6", "NewColumn7")

For Each calcColumns In calculationColumns
'write the additional columns to end of file
xlsht2.Range("A1").End(xlToRight).Offset(0, 1).Value = calcColumns
Next calcColumns

The above code works great. However, now in Row A2, I want to insert Formulas into each of those new columns. I am trying to do the following but it does not insert anything.

Code:


fcalc = Array("=IF(ISBLANK(W2),0,IF(AE2=""T"",0,1))", "=IF(ISBLANK(AJ2),0,IF(AND(AJ2=""0000001756"",AE2=""T""),1,0))", "=IF(ISBLANK(AJ2),0,IF(AJ2=""0000001756"",0,1))", "=IF(ISBLANK(P2),0,IF(AND(I=""19"",ISBLANK(Y2)),1,0))", "=IF(ISBLANK(Q2),1,0)", "=IF((AS2+AT2+AU2+AV2+AW2)=0,1,0)", "=SUM(AS2:AX2)", "IF(DateValue(MONTH(K2)&" / "&Day(K2)&" / "&Year(K2)+65)<Date(),1,0)")

'store a counter to determine the needed offSet
count = -7
For Each fCalculation In fcalc
xlsht2.Range("A2").End(xlToRight).Offset(0, count).Formula = fCalculation
count = count - 1
Next fCalculation


Viewing all articles
Browse latest Browse all 50123

Trending Articles