# Multiplication of 2 rows and storing in new column

When we multiply two columns by writing the formula in write cell,how to create a new data column and store the result of (multiplication of 2 rows) in the new column.
can you please share the code.

@anjani_priya

row(“Result”) = CDbl(row(“Column1”)) * CDbl(row(“Column2”))

Hello @anjani_priya, try something like this:

Excel Application Scope
Input: Path to Excel File

Input: Excel sheet name, Range, Output DataTable: dtData

Assign

For Each Row in dtData
Assign
Double value1 = Convert.ToDouble(row(“Column1”)) ’ Replace “Column1” with your column name
Double value2 = Convert.ToDouble(row(“Column2”)) ’ Replace “Column2” with your column name
Double result = value1 * value2
Assign
row(“Result”) = result
End For Each

Write Range
Input: Excel sheet name, Range: “A1” (or the desired starting cell), DataTable: dtData

Cheers! Hey @anjani_priya ,

Hope it helps you out!

in write cell we cant create variable right.
i wrote the muliplication formula in write cell and i want to save that by creating new column called total

@anjani_priya

assign that value to a variable

total=CDbl(row(“Column1”)) * CDbl(row(“Column2”))

and pass that variable in the write cell activity

I took write cell and wrote the formula. How to create another column and store the values in new column.

@anjani_priya

Cheers

@anjani_priya

Two ways

1. Write the formula in the excel cell directly using write formula activity and then use auto fill range to fill the formula to all the cells till the end…formula can be `"=B2*C2"`

2. If when read into dattable if both the column type are same then just add a new column using add data column and then use assign with expression…which will apply for all rows `dt.Columns("NewColumn").Expression = "[Column1Name]*[Column2Name]"`

Cheers

how can i create new column here and save the data in new column