ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Possible to select a range of cells from a Shape Object (https://www.excelbanter.com/excel-programming/361121-possible-select-range-cells-shape-object.html)

Gummy

Possible to select a range of cells from a Shape Object
 
Hello,

I was wondering if it is possible to draw a rectangle on the screen, then
determine all the cells that the rectangle is over?

I know the opposite can be done. Jon Peltier has posted code where you
select a range and then the chart resizes to that range. His code can be
found he
http://peltiertech.com/Excel/Charts/...tCreation.html

Thanks for the help.

-Rob



Dave Peterson

Possible to select a range of cells from a Shape Object
 
You can get the topleftcell and the bottomrightcell by using something like:

Option Explicit
Sub testme()

Dim myRect As Rectangle
With Worksheets("Sheet1")
Set myRect = .Rectangles("rectangle 1")

MsgBox myRect.TopLeftCell.Address(0, 0) & vbLf & _
myRect.BottomRightCell.Address(0, 0)
End With
End Sub



Gummy wrote:

Hello,

I was wondering if it is possible to draw a rectangle on the screen, then
determine all the cells that the rectangle is over?

I know the opposite can be done. Jon Peltier has posted code where you
select a range and then the chart resizes to that range. His code can be
found he
http://peltiertech.com/Excel/Charts/...tCreation.html

Thanks for the help.

-Rob


--

Dave Peterson


All times are GMT +1. The time now is 06:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com