[VSTO] SheetChange question.

jung 21 Reputation points
2021-08-10T09:35:06.32+00:00

When the user adds a row (B2),

I want to copy B1 row data to B2 row.

Although "SheetChange" is used, the information on B1 is not retrieved and only EMPTY are output.

How can i get B1 value?

void ThisWorkbook_SheetChange(object Sh, Excel.Range Target)
        {


            try
            {

                Excel.Worksheet ws_active = Globals.ThisAddIn.GetActiveSheet();

               int column_index = Target.Column;
                int row_index = Target.Row;


                imsi_break = Convert_object_to_string(ws_active.Cells[row_index - 2, column_index].Value); //get only empty value
                imsi_break = Convert_object_to_string(ws_active.Cells[row_index - 1, column_index].Value); //get only empty value
                imsi_break = Convert_object_to_string(ws_active.Cells[row_index, 6].Value);
                imsi_break = Convert_object_to_string(ws_active.Cells[row_index + 1, 6].Value); //get real value
                imsi_break = Convert_object_to_string(ws_active.Cells[row_index + 2, 6].Value);

            }
            catch (Exception)
            {


            }
        }
Microsoft 365 and Office | Development | Other
0 comments No comments
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.