Writing Excel Formula from UiPath to Excel not working

Hello everyone,

I tried several ways to fill in excel formula “=VERWEIS(2;1/(A1:O1<>”“);A1:O1)” in excel cells via uipath but excel does not recognize it as formula showing #NAME? in the excel cell (tried building datatable and write range (error “range does not exist”), tried via excel application scope and write cell, tried write cell (workbook)…)

Did anyone had a similar problem getting working excel formel into excel via uipath?

Many Thanks!

Welcome to uipath community
use EXCEL APPLICATION SCOPE and use READ RANGE ACTIVITY and get the output with a variable of type datatable named dt
–now use FOR EACH ROW activity and pass the dt as input
–inside the loop use WRITE CELL activity and mention the range as
it can C or any column where you want to use this formula
and mention the value like this

Cheers @bijo153

1 Like


any text that you use to write cell or write range does not write formulas into excel.

You might have to use a custom snippet.

See below a snippet which you can run in a loop to set cells with formulae

app = New Microsoft.Office.Interop.Excel.ApplicationClass
workbook= app.Workbooks.Open(FilePath)
worksheet = CType(workbook.Worksheets(“Sheetname”), Microsoft.Office.Interop.Excel.Worksheet)
Dim rows_Count As Integer = worksheet.UsedRange.Rows.Count
For i As Integer = 0 To rows_count
worksheet.Range(“Column to be entered” + i.ToString).FormulaLocal =“Formula to be entered here with = sign”
app.DisplayAlerts = False
range = Nothing
worksheet = Nothing
workbook = Nothing
app = Nothing
Catch ex As Exception
End Try

Hope this helps :slight_smile:

1 Like

Can you check the format once again @bijo153? I hope the formula itself is wrong. Make sure the formula which is working in excel is assigned to a string variable and then pass it to the activity write range

I am reading the formula from one cell and writing it though out the column however uipath is writing the formula as value, thus it is not generating the correct output.
designer view


@Raghavendraprasad, did the VB code need office installed in the machine ?

how we use the code? using invoke code ?

You can use the activity invoke code for c# or vb.net, and use start process for VB Script or call the script file directly, or if it is VBA (Macro) you can use Invoke VBA or Execute macro (using Excel app scope)


@Raghavendraprasad , for the code you are typed above, and if i use invoke VBA code, did i need Office installed ??

Yes it uses the Excel App object.