The type of the variable is different and an error occurs.:変数の型のエラー

filter_excel _20180606.xaml (10.3 KB)
excelのsheet1のヘッダーにflagという項目があります。
flagにAという値があれば、sheet2に値を貼り付けたいと思います。
しかし、変数の型が異なりエラーとなります。
エラー内容:
For each : Unable to cast object of type ‘System.Data.DataRow’ to type ‘System.String’.
ご教示いただければと思います。

There is an item called flag in the header of sheet 1 of excel.
If flag has a value of “A”, I would like to paste a value on sheet 2.
However, the type of the variable is different and an error occurs.

error contents:
For each: Unable to cast object of type ‘System.Data.DataRow’ to type ‘System.String’.

I hope to teach you.
master3.xlsx (12.3 KB)

Hi @matrix99999 try reading the excel using excel scope as sometimes the formula values are not read properly when read otherwise.

filter_excel _20180606.xaml (13.8 KB)

dear sir.

Thank you very much.
I tried it.
If “A” is in the item of flag, paste the value of that line on sheet2.
However, I will search the value of the last line.

I am sorry without my knowledge.
Can you please teach me?

Hi, I have made an easy solution. You can see the attached file

We will select the row containing ‘A’ to a New table instead of deleting the rows

Hope this helps you!.. tell me if need anymore help

filter_excel _20180606.xaml (15.0 KB)

dear sir.
Excuse my busy place.
Let’s try hard by looking at the “xmal” we received.
If you do not understand, please teach.

HI, we will select Column ‘flag’ = ‘A’ instead of <> ‘A’.

then copy the data to a new table

then write the table in Sheet2