Driving around cells whilst in a macro

Sam40mUK

Board Regular
Joined
Mar 18, 2002
Messages
95
Evening All,
I assume this is an easy request.
If I wish to move to the cell on the right or move multiple cells left, what is the correct code?
Many thanks in advance.
S
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
On 2002-04-09 15:45, Sam40mUK wrote:
Evening All,
I assume this is an easy request.
If I wish to move to the cell on the right or move multiple cells left, what is the correct code?
Many thanks in advance.
S

Hi,

Many ways to do this. What exactly do you want?

ActiveCell.Offset(row,col) is a common method.

Post more detals for a more complete answer.

Bye,
Jay
 
Upvote 0
Hello Jay,
Thanks for the swift response.
Basically I am attempting to End Down to the bottom of a list, then move left two cells and paste a Summary.
The list is a product of a Pivot Table and therefore is of variable length .. hence the End Down and variable nature of left two cells, paste.
I hope this clarifies the situation a little.
Regards
S.
 
Upvote 0
On 2002-04-09 15:59, Sam40mUK wrote:
Hello Jay,
Thanks for the swift response.
Basically I am attempting to End Down to the bottom of a list, then move left two cells and paste a Summary.
The list is a product of a Pivot Table and therefore is of variable length .. hence the End Down and variable nature of left two cells, paste.
I hope this clarifies the situation a little.
Regards
S.

Hi,

Range("C2").End(xlDown).Offset(0, -2) = summary value

or

ActiveCell.End(xlDown).Offset(0, -2) = summary value

This requires that this is run with the Active Cell in the correct column.

Not necessarily the best way, though.

Assuming you have only one Pivot Table on the sheet in columns A:E, then you could do something like the following in your code:

-------------
lastrow = Cells(rows.count,"A").end(xlup).row
Cells(lastrow,"Your Column") = Summary
-------------

This finds the last row and places the
summary in the column of your choice. You could also make the column a determined variable as well.

lastcol = Cells(2,256).End(xltoLeft).Column

and reference 2 columns to the left of that

Cells(lastrow + 5, lastcol - 2) = summary val

for example.

HTH,
Jay
This message was edited by Jay Petrulis on 2002-04-09 16:15
 
Upvote 0
Cheers Jay,
I will have to give your reply a looking at tomorrow.
Meantime thank you for your effort and help.
S
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,240
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top