This piece of code causes error:
CType(DataGridView1.Rows(i).Cells(1).Value, Microsoft.Office.Interop.Excel.Worksheet)
I'd suggest to get dataGridView cell value into string variable:
string sheetname = DataGridView1.Rows(i).Cells(1).Value;
then to create object variable (of Worksheet):
Microsoft.Office.Interop.Excel.Worksheet wsh = xlWorkBook.Worksheets(sheetname);
Now, you can use
Find method[
^]:
How to: Programmatically Search for Text in Worksheet Ranges[
^]
Note that
Find method returns Range object!