Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
tom tom is offline
external usenet poster
 
Posts: 570
Default referencing current range of cells selected

Is there a way to reference the current cell range selected?

For example the following statement select the range A1:B3

Range("A1:B3").Select

However, if I select cells A3: B5 is there a command to set the selection in
VB to that range without specifically indicating the cells. So I highlight
cells A3:B5 then I would like to set that as the range selection and then
perform some actions on that range, then highlight another range of cells and
do the same set of actions.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default referencing current range of cells selected

When you do this:

Range("A1:B3").Select

You can then use:

Selection.Font.Bold = True

Generally speaking it is just as easy to use the range address
(Range("A1:B3")when referring to a range on a one shot basis. However, if
you are going to be referring to a specific range on a repetitive basis you
can either name the range, InsertNameDefine, or Set the range to a
variable. To Set the variable:

Set myRange = ActiveSheet.Range("A1:B3")

Then you can just refer to myRange anywhere in the code and it will know
which specific set of cells you mean. For a single cell, you can always use
ActiveCell for the selected cell. If you have a cell selected and you want
to refer to the entire group of cells around the selected cell, you can use
ActiveCell.CurrentRegion.

All of this information is available in your VBA help files. Access the VB
editor and look up keywords "cell reference" then review the several topics
that the help menu displays.

"Tom" wrote:

Is there a way to reference the current cell range selected?

For example the following statement select the range A1:B3

Range("A1:B3").Select

However, if I select cells A3: B5 is there a command to set the selection in
VB to that range without specifically indicating the cells. So I highlight
cells A3:B5 then I would like to set that as the range selection and then
perform some actions on that range, then highlight another range of cells and
do the same set of actions.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Referencing Cells in a Selected Row dch3 Excel Programming 3 July 11th 07 08:56 PM
referencing selected cells [email protected] Excel Worksheet Functions 2 September 27th 06 07:22 PM
Current Selected Range infojmac[_11_] Excel Programming 5 July 15th 06 10:50 PM
Referencing the First Cell in Any Selected Range maximouse Excel Programming 4 November 1st 05 03:57 AM
Referencing a Column in a Selected Range of Columns Rob G Excel Programming 3 October 21st 04 05:21 PM


All times are GMT +1. The time now is 05:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"