We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Activate Excel cell in C#, VB.NET

Platform: WinRT |
Control: XlsIO

Syncfusion Excel (XlsIO) library is a .NET Excel library used to create, read, and edit Excel documents. Also, converts Excel documents to PDF files. Using this library, you can activate single cell or a range of cells in Excel worksheet.

Steps to set active cell in Excel worksheet, programmatically:

Step 1: Create a new C# console application project.

Create a new C# console application project

Create a new C# console application project

Step 2: Install the Syncfusion.XlsIO.WinForms NuGet package as reference to your .NET Framework application from NuGet.org.

Install NuGet package to the project

Install NuGet package to the project

Step 3: Include the following namespace in Program.cs file.


using Syncfusion.XlsIO;



Imports Syncfusion.XlsIO


You can activate a cell in Excel worksheet through method call for the cell. Activate() method available under the IRange interface helps to activate the Excel cell.

Step 4: Include the following code snippet in main method of Program.cs file to activate an Excel cell.


using (ExcelEngine excelEngine = new ExcelEngine())
    //Instantiate the Excel application object
    IApplication application = excelEngine.Excel;
    //Create a new Excel workbook
    IWorkbook workbook = application.Workbooks.Create(1);
    //Get the first worksheet in the workbook into IWorksheet
    IWorksheet worksheet = workbook.Worksheets[0];
    //Activate a cell and assign text in it
    worksheet.Range["E5"].Text = "Active cell in this worksheet is E5";
    //Autofit the column
    //Save the Excel document



Using excelEngine As ExcelEngine = New ExcelEngine()
    'Instantiate the Excel application object
    Dim application As IApplication = excelEngine.Excel
    'Create a new Excel workbook
    Dim workbook As IWorkbook = application.Workbooks.Create(1)
    'Get the first worksheet in workbook into IWorksheet
    Dim worksheet As IWorksheet = workbook.Worksheets(0)
    'Activate a cell and assign text in it
    worksheet.Range("E5").Text = "Active cell in this worksheet is E5"
    'Autofit the column
    'Save the Excel document
End Using


A complete working sample to activate an Excel cell can be downloaded from ActivateCell.zip.

By executing the program, you will get the output Excel file as follows.

Cell activated in Excel document

Cell activated in Excel document

Syncfusion .NET Excel library also supports activating a range of cells. Use the following code snippet to activate a range of cells in Excel worksheet.


//Activate cells and assign text
worksheet.Range["E5:E10"].Text = "Active cells in this worksheet are from E5 to E10";



'Activate cells and assign text
worksheet.Range("E5:E10").Text = "Active cells in this worksheet are from E5 to E10"


Range of cells activated in Excel document

Range of cells activated in Excel document

Take a moment to peruse the documentation where you will find other options like accessing a cell or range, relative range, used range of worksheet, precedent and dependent cells, copy or move a range, skip blank cells, find and replace, data sorting, data filtering, hyperlinks and more with code examples.

See Also:

Merge Excel cells in C#, VB.NET

Protect certain cells in C#, VB.NET

Format comments in a cell

Set link break inside a cell

Delete rows and columns in an Excel worksheet

Click here to explore the rich set of Syncfusion Excel (XlsIO) library features.


Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer the link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.


You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile