Select Excel Cell in VBA, C#.NET and Java

In this article, we will learn how to select Excel cell in

Select Excel Cell in VBA

In Excel VBA, we use Range object to select Excel cell. The Range object is a child object of Worksheet object which in turn is a child object of Application object.

The following sample code uses Range object to select Excel cell C4.

'Select Excel cell C4 in worksheet.
Application.ActiveSheet.Range("C4").Select

After, you execute this code, you will find cell C4 is selected as shown in this image.

Select Excel Cell in VBA i.e. Visual Basic for Applications

Select Excel Cell in C#.NET

You can also select Excel cell in C#.NET or in any other .NET Framework supported language e.g. VB.NET etc. using Aspose.Cells for .NET API with the following code.

// Select Excel cell D6 in worksheet.
workbook.Worksheets[0].ActiveCell = "D6";

After the execution of this code, you will find cell D6 is selected as shown in the following image.

Select Excel Cell in C# using Aspose.Cells for .NET

Select Excel Cell in Java

Similarly, you can select Excel cell in Java using Aspose.Cells for Java API with the following code.

// Select Excel cell E8 in worksheet.
workbook.getWorksheets().get(0).setActiveCell("E8");

After the execution of this code, you will find cell E8 is selected as shown in the following image.

Select Excel Cell in Java using Aspose.Cells for Java

 

Leave a comment

Design a site like this with WordPress.com
Get started
search previous next tag category expand menu location phone mail time cart zoom edit close