Moving right in a macro

G

Guest

Want to highlight a cell (for example A7), highlight it with a background
colour, move right one cell, highlight it with a background colour, move
right one cell, highlight it - for a total of 15 cells.
If I do this by recording a macro, when I run the macro from cell A15, the
macro highlights A15 then moves to B7 not B15.
How can I accomplish highlighting a continguous range of 15 horizontal cells?
 
D

Dave Peterson

All the same color?

If yes, you could get all 15 cells with something like:

ActiveCell.Resize(1, 15).Interior.ColorIndex = 3
 
E

Earl Kiosterud

BJS,

The macro recorder was not set to relative mode, so it went to the absolute
cell. Record the macro again. In the Stop Recording toolbar (View -
Toolbars), make sure the relative button is lit. You will want to have
selected the starting cell before you start the recorder, or it will record
that move.

Or you could use the existing macro. Move right with

Activecell.offset(0,1).select
 

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

Top