c# excel assign cell value to another worksheet

I am creating an excel workbook by copying a template sheets from another workbook and renaming them.  What I need to do is sum all the created sheets on the first sheet.  When I assign the value to the cell(worksheet.Cells[3, 2]), the cell's value is System.__ComObject.  I don't even set the value of the child cell in code, it is a formula in the template.
This is my code:

                        Worksheet worksheet = ((Worksheet)originalWorkbook.Worksheets["Division Template"]);
                        worksheet.Copy(Missing.Value, previous);
                        worksheet = ((Worksheet)workbook.Worksheets["Division Template"]);
                        worksheet.Name = "Division " + ddlDivision.SelectedItem.Text;

                        while (dReader.Read())
                            previous = writeSU(dReader["SU_ID"].ToString(), dReader["Name"].ToString(), previous);

                        int i = 0;
                        foreach (Worksheet sheet in workbook.Worksheets)
                            if (sheet.Name != "Division " + ddlDivision.SelectedItem.Text)
                                if (i == 1)
                                    worksheet.Cells[3, 2] = "='" + sheet.Name + "'!B3";
                                    worksheet.Cells[3, 2] = worksheet.Cells[3, 2].ToString() + "+'" + sheet.Name + "'!B3";


        private Worksheet writeSU(string SU_ID, string Employee_Name, Worksheet previous)
            Worksheet result;

            result = ((Worksheet)originalWorkbook.Worksheets["SU Template"]);
            result.Copy(Missing.Value, previous);
            result = ((Worksheet)workbook.Worksheets["SU Template"]);
            result.Name = SU_ID + " " + Employee_Name;
            return result;
Who is Participating?

Improve company productivity with a Business Account.Sign Up

BuggyCoderConnect With a Mentor Commented:
to apply formula you need to work with range object. please go through the following MSDN Example, i am sure it will help you:-

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.