Solved

Find out Excel active range?

Posted on 1998-06-16
4
256 Views
Last Modified: 2012-05-04
I'm trying to write an Excel macro to show percentage deviation from a certain amount.

The macro should operate only on a range of cells which the user has selected in a worksheet. I know how to find out which worksheet is active, and which single cell ("ActiveCell" reference) - but how do I find out which  _range_ of cells is selected when the user clicks the button to run the macro ?

The ideal code snippet would do the following:

     Find active range
     Perform any cell-by-cell operation on cells in that range

I was hoping that I could refer to "ActiveRange", but that doesn't exist !

I'm interested in any answer, but particularly a solution that would work on Excel 7.0 (Office 95).  Please supply me with a working example of the code if possible. I'm new to Experts Exchange, so if you think the points should be higher let me know.

thanks  a lot,

Ernesto Orega



0
Comment
Question by:cpdata
  • 3
4 Comments
 
LVL 3

Accepted Solution

by:
shalbe earned 100 total points
ID: 1609767
Ernesto,

Use "selection" as follows to get the address of a selection set.  

 myRange = Selection.Address
    MsgBox myRange

Steve
0
 
LVL 3

Expert Comment

by:shalbe
ID: 1609768
If you need more help in how to apply it, let me know and I'll help you.
0
 

Author Comment

by:cpdata
ID: 1609769
your code does exactly what I was after - thanks a lot !

Ernesto
0
 
LVL 3

Expert Comment

by:shalbe
ID: 1609770
Glad I could help Ernesto. Thanks for the points.

Steve
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Have you ever had the experience that you had to follow 10 steps over and over again every time when you need to nicely forward an important email to your manager? Fear no more! With the help of the Quick Steps feature in Outlook 2010, your old chor…
No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

809 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