Sum Forula using variables

S

Sue

I have a position where I want a total. I have cells (Lower and Upper) that I
want to sum between. I have checked the addresses of these range variables
and they are correct (and the data between them is numeric). But I can not
seem to get it right in the "sum" formula. I have tried using using the range
variables, the address (string) variables, I have put quotes all over the
place - Help!!

'Record position for subtotal
Set SubPos = ActiveCell
SubPosAddress = SubPos.Address

'Coordinates of lower cell in total
Set LowerCell = ActiveCell.Offset(0, -1)
LowerAddress = LowerCell.Address

ActiveCell.End(xlUp).Select

'Coordinates of upper cell in total
Set UpperCell = ActiveCell.Offset(1, -1)
UpperAddress = UpperCell.Address

'Return to marked position
SubPos.Select

** ActiveCell.Formula = "=Sum(Lowercell : Uppercell)"
This line is rubbish but it is the idea I want.
 
S

Stefi

ActiveCell.Formula = "=Sum(" & LowerAddress & ":" & UpperAddress & ")"

Regards,
Stefi

„Sue†ezt írta:
 
S

Sue

Thanks, that solves my problem. I did try many & and " but when I had some
right I always had something wrong. Thanks so much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top