Calc specifics column Excel

Hello Friends, I need a help here… I need calc the specifics values in columns (H,I,J,K) (with parameter: calc the column up until find a value in column (M))

Exp:I need calc the column H completely and put in a variable.

After find value in (M) I will to next row and begin a new calc.

Firstly read excel into a datatable, then use a for each row loop.

You can the do the calculation also with an if decision to check if

Not String.IsNullOrWhitespace(item(12).ToString)

This will check if column M is not empty - if true then do new calculation …

If you provide more understanding for requirements, I can try to help you more

Hello @TimK, with this (Not String.IsNullOrWhitespace(item(12).ToString)) I will just calc 12?
Because in my excel in the columns my values gonna change.

hi Diego_Pin,

can you please share the excel file… so, i can provide you the solution.

Cópia de Padrão_SAP automatização das guias.xlsx (15.7 KB)

if your column structure will stay the same, then what I have provided will look for column 12.

If you want to use column name which is more secure you can use -

Not String.IsNullOrWhitespace(item(“COLUMN”).ToString)

1 Like

Hello @TimK, Thnks man… can you do a explain how I can calculate that columns?
Is my first time doing this.

So is your calc to add the values or multiply the values etc?

You can add them by accessing each item and converting it to a double.
Inside the for each loop you can use this:
in an assign

Sum = CDbl(row.item(7).ToString)+CDbl(row.item(8).ToString)+…

You would then use the if statement with

Not String.IsNullOrWhitespace(row.item(12).ToString)

Store Sum in a list or something then start new calculation