going 3 columns over in a macro

B

ben

Hello,

I recorded a macro and have a small detail I need to fix, but am unsure how
to do it. At the end of the recording of the macro, I hit the right arrow 3
times to move over 3 cells across. The problem is that the macro recorded it
as follows: Range("F834").Select

How do I change that line from an absolute reference to a relative one so
that the cell I am on is 3 to the right?

Thanks,
Ben
 
T

T. Valko

Try replacing this:

Range("F834").Select

With this:

ActiveCell.Offset(0, 3).Select

Whatever cell you're in when the macro runs will determine where you end up.
If you're in A1 you'll end up in D1.
 
D

Don Guillett

As always, post your code for comments. It's almost always NOT necessary to
select a cell.
 
B

ben

Don said:
As always, post your code for comments. It's almost always NOT necessary
to select a cell.

I don't know what you mean since this would depend on what the user (me)
wants to do. After highlighting the data in one excel file, I do a special
paste with just the values of the highlighted region in another sheet (in
another file) where the cell it finishes up on is 3 to the right of the
paste so I can manually enter into that column data. I wanted this done
through a macro, so I recorded one which worked fine except for which cell
it ended up on which was not 3 to the right but ended up on the cell I ended
with when recording the macro.
 
D

Don Guillett

Then Biff gave you a solution. You could have also used OFFSET. I repeat
that you should always post your code for comments and improvement
suggestions.
 

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