# Solved: Looking for easy way to "Extend Selection" in MS Excel VBA



## Gregor1234 (Jun 3, 2004)

I am looking for an E-Z way to select a certain number adjacent cells in an MS Excel VB macro.

Yes, I know, I know, there are a bunch of ways to do this but I was wondering if there were an easy way _similar to the way you can do this in a MS Word_ VB Macro.

In MS Word if you have an active selection you can extend it (in this case, seven characters to the right) thusly:

Selection.MoveRight Unit:=wdCharacter, Count:=7, Extend:=wdExtend

This is great because you don't have to figure out where you are or calculate at which character the selection should end. You just tell it to include the next seven characters to the right.

Is there an analogous, simple method for cells in Excel VB?


----------



## Zack Barresse (Jul 25, 2004)

Hi there,

Of course there is. Some commands which you might be interested in are Offset and Resize. Although we need to know what you are trying to do. In Excel VBA there is little need - almost none - to select or activate anything. You can work with the ranges as desired without performing these inefficient actions. What are you trying to do? Here are a couple of ways to get a larger extended selection...

```
'Selects from the activecell, the 7 cells to the right
Activecell.Resize(1, 8).Select

'Selects the cell 7 cells to the right of the activecell
Activecell.Offset(0, 7).Select

'Selects the cell 7 cells to the right of the activecell, then extends the selection to the 7 next columns (same row)
Activecell.Offset(0, 7).Resize(1, 8).Select
```
HTH


----------



## Gregor1234 (Jun 3, 2004)

Fantastic- Just what I wanted.

Just wanted a quick way, say to manually select a cell, then activate a macro that'll turn the current cell and say the next 5 to the right red or maybey put a border or some other formatting thing. Just a convenience thing written in the moment for a specific situaton.

The resize method is exactly what I was looking for... just didn't know what it was called.


----------



## Zack Barresse (Jul 25, 2004)

Glad to help. Make sure you understand you do not need to select those 5 cells...


```
Activecell.Resize(1, 6).interior.Colorindex = 6
```
Take care.


----------

