I like WarrenG's idea of ββa dropdown event. If it works, it seems perfect. Otherwise, I would recommend using the Sheet_Activate event of the workbook. This works when sheets are created or deleted, at least if done by the user.
In C #, you need to instantiate an event and create a handler. In fact, you can do this in the Form_Load event, so creating an instance of the form creates an event handler. You need to set up links to Interop.Excel so that your Form.cs code looks something like this:
So your Form_Load event looks something like this:
using Excel = Microsoft.Office.Interop.Excel; namespace ExcelWorkbook1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { Globals.ThisWorkbook.SheetActivate += new Excel.WorkbookEvents_SheetActivateEventHandler( ThisWorkbook_SheetActivate); } private void ThisWorkbook_SheetActivate(object Sh) {
EDIT: I found the base code on this MSDN site .
source share