ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   ADD Macro - xlup plus xlto right (https://www.excelbanter.com/excel-worksheet-functions/79925-add-macro-xlup-plus-xlto-right.html)

Danny

ADD Macro - xlup plus xlto right
 
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,

Trevor Shuttleworth

ADD Macro - xlup plus xlto right
 
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


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




Jim Thomlinson

ADD Macro - xlup plus xlto right
 
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...
--
HTH...

Jim Thomlinson


"Danny" wrote:

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,


Danny

ADD Macro - xlup plus xlto right
 
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

"Jim Thomlinson" wrote:

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...
--
HTH...

Jim Thomlinson


"Danny" wrote:

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,


Jim Thomlinson

ADD Macro - xlup plus xlto right
 
with Range("A10")
.value = .end(xlup).value + .end(xlup).end(xlToRight).value
end with
--
HTH...

Jim Thomlinson


"Danny" wrote:

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

"Jim Thomlinson" wrote:

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...
--
HTH...

Jim Thomlinson


"Danny" wrote:

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,


Danny

ADD Macro - xlup plus xlto right
 
Perfect! Thanks a lot!

"Jim Thomlinson" wrote:

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

Jim Thomlinson


"Danny" wrote:

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

"Jim Thomlinson" wrote:

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...
--
HTH...

Jim Thomlinson


"Danny" wrote:

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,



All times are GMT +1. The time now is 01:05 AM.

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