Need to run macros for using formulae in excel for uipath

I have to perform formulae in sheet1 excel where it has to select two cells from sheet2 and this it has to do for all the rows count that are available in sheet2. Here the rows are dynamic.
The formula is like this " =IF(Sheet2!A2,Sheet2!D2," “)” and this has to get continue till all rows are done.
I tried using UiPath but able to write value in cell but not getting output.
PLease help me to complete it using macros and UiPath both.

I am enclosing the excel for reference
Macro_test.xlsx (102.6 KB)

Also please try to modify this macro with arguments that can pass value :
Sub Macro4()

’ Macro4 Macro

ActiveCell.FormulaR1C1 = “=IF(Sheet2!RC[-1],Sheet2!RC[2],”" “”)"
Selection.AutoFill Destination:=Range(“B2:B20”), Type:=xlFillDefault
End Sub

Here sheetname, rowindex and range index is dynamic but rows i.e A,B are static

Hello @deepaksvg99 ,

To add the formula in Excel , use write cell as shown below.


Hi @deepaksvg99

Try this way

After giving formula in Write Cell use Auto Fill activity to fill the total rows in that column.

I hope it helps!!

Hi Sreelatha,
Thanks for the reply, I tried the way that you suggested, it works when we apply formulae directly.
But when we apply dynamic value those are not working.
Will this work dynamically like below:
“=IF(”+“'”+ sheetname+“”+“'!A”+“”+ rowindex.tostring+“,”+“'”+ sheetname+“”+“'!D”+“”+ rowindex.tostring+“,”+“”" “”"
here sheename= excel sheetname
rowindex= the cell from which we have to get info .

Hi Lakshman,
Thanks for your reply, I tried with your suggestion, but when trying dynamically the formulae is not working. I tried like below:
“=IF(”+“'”+ sheetname+“”+“'!A”+“”+ rowindex.tostring+“,”+“'”+ sheetname+“”+“'!A”+“”+ rowindex.tostring+“,”+“”" “”"

Can you please check it

Hi @deepaksvg99

Please find the below xaml

2 Methods are done (Static and Dynamic Values)

VLOOKUP Task.xaml (18.5 KB)

Macro_test.xlsx (133.2 KB)



If you find the solution for your issue. Please mark it as solution to close the thread and others also helped.


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.