Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Giz Giz is offline
external usenet poster
 
Posts: 15
Default setting range from activecell in macro

Hi,
I am trying to select a range of cells after selecting a cell based on an
activecell.offset. For example, a line in my code looks like this:

ActiveCell.Offset(2, -3).Select

Now I want to select a range of three cells (the selected cell and one cell
before and after the selected cell). The absolute location will not always be
the same, therefore can not select range based on absolute cell references
(i.e. A1:A3 or .cells(1,3),.cells(3,3) for example). Can't figure out how to
do it. Any help??
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default setting range from activecell in macro

Giz,

Use the Resize method:

ActiveCell.Offset(0, -1).Resize(1, 3).Select
ActiveCell.Offset(-1, 0).Resize(3, 1).Select

Note that you rarely need to select anything within code to make changes....

HTH,
Bernie
MS Excel MVP

"Giz" wrote in message
...
Hi,
I am trying to select a range of cells after selecting a cell based on an
activecell.offset. For example, a line in my code looks like this:

ActiveCell.Offset(2, -3).Select

Now I want to select a range of three cells (the selected cell and one

cell
before and after the selected cell). The absolute location will not always

be
the same, therefore can not select range based on absolute cell references
(i.e. A1:A3 or .cells(1,3),.cells(3,3) for example). Can't figure out how

to
do it. Any help??



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
Data Validation - List - Setting Range from a macro dhstein Excel Discussion (Misc queries) 5 May 14th 09 01:11 PM
ActiveCell in a Range? Filo Excel Discussion (Misc queries) 3 May 22nd 07 09:52 PM
Trigger macro if an Activecell is within a specific Range helmekki[_44_] Excel Programming 0 October 24th 04 01:36 PM
Trigger macro if an Activecell is within a specific Range helmekki[_43_] Excel Programming 2 October 23rd 04 03:56 PM
Macro in VBA: Setting a variable print range HELP NEEDED!! Ron de Bruin Excel Programming 1 July 21st 04 05:45 PM


All times are GMT +1. The time now is 04:24 AM.

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

About Us

"It's about Microsoft Excel"