View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sue Sue is offline
external usenet poster
 
Posts: 285
Default Sum Forula using variables

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.