views:

117

answers:

1

Is it possible to show the cell info when any cell on a worksheet is clicked? For example, if cell A1 is clicked it will show A1, and so on... If yes, can you show example?

I need this because I have a c# program which should know which cell was clicked.

+2  A: 

You need to use the WorksheetSelectionChange event, there is sample code on MSDN - http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.worksheet.selectionchange.aspx

private void WorksheetSelectionChange()
{
this.SelectionChange += 
    new Excel.DocEvents_SelectionChangeEventHandler(
    Worksheet1_SelectionChange);
}

void Worksheet1_SelectionChange(Excel.Range Target)
{
this.Application.StatusBar = this.Name + ":" +
    Target.get_Address(missing, missing,
    Excel.XlReferenceStyle.xlA1, missing, missing);
}
Lunatik