Identify Selected Cells in Excel using C#

Posted on 2008-11-04
Last Modified: 2012-06-22
I am writing a C# addin for Excel.

I would like to get the currently selected cells in Excel so that I can perform some action using the values in those cells.

How can I get the currently selected cells into a Microsoft.Office.Interop.Excel.Range object (or something else suitable)?  I've tried using the Worksheet.UsedRange object but it's not quite right.
Question by:openshac
    LVL 46

    Accepted Solution

    Use Application.Selection()

    LVL 6

    Author Comment

    Got it.

    I just use (Range)applicationObject.Selection

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
    The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
    This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now