How to insert a formula into a Datatable?

Hi Team

How do I insert this formula into a table?

Used Write Cell but failed

datetime.now.AddMonths(-1).ToString(“=ВПР(B5;‘yyMM01_Расчет лимита’!$B$5:$S$31;18;0)”)

Hi @Aibek_Abubakirov

Dont need to add datetime.now.addMonths(-1).ToString

just give the formula as

“=ВПР(B5;‘yyMM01_Расчет лимита’!$B$5:$S$31;18;0)” and mention the range

Thanks
Ashwin S

I need datetime.now.addMonths(-1).ToString
to take away one month

Can you help with the problem?

@Aibek_Abubakirov While writing formula, you are trying to use .Net functions in excel. It wont work in that way as it requires only excel formula.

I would suggest you to make this action first “=ВПР(B5;‘yyMM01_Расчет лимита’!$B$5:$S$31;18;0)”.

Then, take that value from the excel again and do the calculation datetime.now.addMonths(-1).ToString

Else, have an excel formula like this =DATE(YEAR(A2),MONTH(A2)-1,DAY(A2)) after having a date in the particular column

1 Like

Can you explain more please?

@Aibek_Abubakirov I think you are having a formula to extract the date value from different sheet. There are 2 ways you can get this done. Once after extracting the date value to a particular column (Say Column C),

  1. Put another formula in next column (Say at D2) to deduct 1 month. like this **=DATE(YEAR(C2),MONTH(C2)-1,DAY(C2))**
    
  2. Else, read the date values from the excel (column C) , do manipulation **datetime.now.addMonths(-1).ToString** and write again in the same excel in different column (D or E).
    

It is up to you how do you want to.

1 Like

how was it used for the second time?