setting range from activecell in macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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??
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top