Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel - Simple Macro Question 3

Status
Not open for further replies.

NiceButDim

Programmer
Feb 12, 2002
154
0
0
GB
I hope that I am in the correct forum for this;
I want a simple macro that copies the cell that is to the left of my current cell, into my current cell.

When I record the macro it looks like this;
Range("C11").Select
Selection.Copy
Range("D11").Select
ActiveSheet.Paste

My problem is, the macro has hard coded reference to the cells that I was on when I recorded the macro (i.e. C11 & D11). How would I change this to say 'current cell' and 'cell to the left'.

Any help appreciated.

john.
 



Hi,
Code:
  selection.offset(0,-1).copy selection


Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Would keystroke suffice?

Ctrl+R copies the contents of the cell to the left into the current cell.

Ctrl+D does the same for the cell above.

 
I love my keyboard shortcuts but I've never seen those before, [1726.

Thanks for the tip, have a pointy purple shiny thing!

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ181-2886 before posting.
 
My problem is, the macro has hard coded reference to the cells that I was on when I recorded the macro (i.e. C11 & D11). How would I change this to say 'current cell' and 'cell to the left'.

For future reference there is a button on the "stop recording" toolbar that toggles between recording hard coded references and relative references. (This is the toolbal that appears when you start recording.)


Gavin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top