ADD Macro - xlup plus xlto right

D

Danny

Hi,

I tried to record macro step by step but the macro will not write it for me.

How can I write a macro for: + xlup + xlto right
I just want to add two numbers but using xlup and xltotheright.

Thank you,
 
T

Trevor Shuttleworth

Not quite sure what you want to do but here are some examples:

This one goes up to the bottom non-blank row in column B and adds that to
the value in column C

MsgBox Range("B65536").End(xlUp).Value + _
Range("B65536").End(xlUp).Offset(0, 1).Value

This adds the value in the cell above to the cell next to that

MsgBox ActiveCell.Offset(-1, 0).Value + _
ActiveCell.Offset(-1, 1).Value

Hope this helps

Regards

Trevor
 
J

Jim Thomlinson

Try adding this line of code where you want to go up and to the right...

MsgBox ActiveCell.End(xlUp).End(xlToRight)

It will display the value you are looking for without moving the cursor...
 
D

Danny

Thank you for your response.

All I need is, in a cell, how would I add the figures up using xlup then add
xl to right. Say If the active cell is in a10, how can I add +a4+d4 using
xlup and xlToRight

Can I please have a macro without the message box?

Thanks Again
 
J

Jim Thomlinson

with Range("A10")
.value = .end(xlup).value + .end(xlup).end(xlToRight).value
end with
 
Top