ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Setting var to selected Range (https://www.excelbanter.com/excel-discussion-misc-queries/173637-setting-var-selected-range.html)

El Bee

Setting var to selected Range
 

I discovered the following statement
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select

now I want to set a var to the selected range.

Can anyone help; this VB stuff is all new to me and I really appreciate the
help I have received from many of the Guru's on this site!!!

Thanks again for your time and knowledge.

El Bee

Dave Peterson

Setting var to selected Range
 
dim myRng as range
set myrng = Range(Selection, ActiveCell.SpecialCells(xlLastCell))

or after your last line:

set myrng = selection



El Bee wrote:

I discovered the following statement
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select

now I want to set a var to the selected range.

Can anyone help; this VB stuff is all new to me and I really appreciate the
help I have received from many of the Guru's on this site!!!

Thanks again for your time and knowledge.

El Bee


--

Dave Peterson

Earl Kiosterud

Setting var to selected Range
 
El Bee

Dim MyRange As Range

Now at the point where you want to capture the range, do this statement:
Set MyRange = Range(Selection, ActiveCell.SpecialCells(xlLastCell))

Now range MyRange will be the cells indicated by your statement
--
Regards from Virginia Beach,

Earl Kiosterud
www.smokeylake.com

-----------------------------------------------------------------------
"El Bee" wrote in message
...

I discovered the following statement
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select

now I want to set a var to the selected range.

Can anyone help; this VB stuff is all new to me and I really appreciate the
help I have received from many of the Guru's on this site!!!

Thanks again for your time and knowledge.

El Bee





All times are GMT +1. The time now is 05:33 AM.

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