Learn how to a build a cloud-first strategyRegister Now


Identify Selected Cells in Excel using C#

Posted on 2008-11-04
Medium Priority
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 48

Accepted Solution

Wayne Taylor (webtubbs) earned 2000 total points
ID: 22875393
Use Application.Selection()


Author Comment

ID: 22875400
Got it.

I just use (Range)applicationObject.Selection

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a serious pitfall that can happen when deleting shapes using VBA.
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

810 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