[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)
            {


            }
        }
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,966 questions
0 comments No comments
{count} votes

Your answer

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