ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   going 3 columns over in a macro (https://www.excelbanter.com/new-users-excel/202289-going-3-columns-over-macro.html)

ben

going 3 columns over in a macro
 
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. Valko

going 3 columns over in a macro
 
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.

--
Biff
Microsoft Excel MVP


"ben" wrote in message
...
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




Don Guillett

going 3 columns over in a macro
 
As always, post your code for comments. It's almost always NOT necessary to
select a cell.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"ben" wrote in message
...
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



ben

going 3 columns over in a macro
 
Don Guillett wrote:
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.

Don Guillett

going 3 columns over in a macro
 

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.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"ben" wrote in message
...
Don Guillett wrote:
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.



ben

going 3 columns over in a macro
 
No problem. I'll certainly do that in the future.

Don Guillett wrote:

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.



All times are GMT +1. The time now is 10:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com