Worksheet Change Event and EXCELDNA with C#

1,312 views
Skip to first unread message

Jim

unread,
Jul 16, 2013, 6:53:57 AM7/16/13
to exce...@googlegroups.com
Hi,
I need to subscribe to an event
Worksheet_Change to get added values from sheet
once they are added. Currently I am using Timer to scan my worksheet.
I would like to do it in ExcelDNA with C#


VBA code

Private
Sub Worksheet_Change(ByVal Target As Range)
'here, check whether Target, a Range, is one of your "trigger" cells, 'and if it is, react accordingly

MainSheetHasChanged = True
 
End Sub

By the way are there any other ways to do it more efficiently.

thanks

pb19...@gmail.com

unread,
Mar 30, 2016, 12:12:29 PM3/30/16
to Excel-DNA
 public class Class1 : IExcelAddIn

{
Microsoft.Office.Interop.Excel.Application xlapp = (Microsoft.Office.Interop.Excel.Application)ExcelDnaUtil.Application;
      //  int eventCounter = 0;
        Workbook Wb_ ;

        public void AutoOpen()
        {
                        xlapp.WorkbookActivate += xlapp_WorkbookActivate;

        }

        void xlapp_WorkbookActivate(Workbook Wb)
        {
            Wb.SheetChange += Wb_SheetChange;
            System.Windows.Forms.MessageBox.Show("in activate");

            Microsoft.Office.Interop.Excel.Worksheet ws = Wb.ActiveSheet;

        }

        void Wb_SheetChange(object Sh, Microsoft.Office.Interop.Excel.Range Target)
        {
}
}




This might helps you.
Reply all
Reply to author
Forward
0 new messages