Solved

Find out Excel active range?

Posted on 1998-06-16
4
257 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article will show you how to use shortcut menus in the Access run-time environment.
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

697 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