first and last cells of manually selected regions
I'm writing a script to be run on manually selected regions in
different worksheets in the same workbook. (I'll select one region at a time and then run the script.) How do I programmatically find the first and last cells (upper-left and bottom-right corners) of a manually selected region? Thanks. |
first and last cells of manually selected regions
you can try these statements and see if they work for you selection.range("A1").address selection.specialcells(xlcelltypelastcell).address -- Gary "John Smith" wrote in message ... I'm writing a script to be run on manually selected regions in different worksheets in the same workbook. (I'll select one region at a time and then run the script.) How do I programmatically find the first and last cells (upper-left and bottom-right corners) of a manually selected region? Thanks. |
first and last cells of manually selected regions
Sub aaaa() Dim rng As Range Set rng = Selection.Cells If rng.Areas.Count 1 Then MsgBox "multiple selection" Else MsgBox rng(1).Address & vbCr & rng(rng.Count).Address End If Set rng = Nothing End Sub -- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware (Excel Add-ins / Excel Programming) "John Smith" wrote in message I'm writing a script to be run on manually selected regions in different worksheets in the same workbook. (I'll select one region at a time and then run the script.) How do I programmatically find the first and last cells (upper-left and bottom-right corners) of a manually selected region? Thanks. |
first and last cells of manually selected regions
Are they single area ranges?
with selection msgbox .cells(1).address & vblf & .cells(.cells.count).address end with John Smith wrote: I'm writing a script to be run on manually selected regions in different worksheets in the same workbook. (I'll select one region at a time and then run the script.) How do I programmatically find the first and last cells (upper-left and bottom-right corners) of a manually selected region? Thanks. -- Dave Peterson |
All times are GMT +1. The time now is 10:02 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com