View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ardus Petus Ardus Petus is offline
external usenet poster
 
Posts: 718
Default Help with cell reference

Sub test()
Dim a As Long
Dim isum As Double
a = 20
isum = Application.WorksheetFunction.sum(Range( _
Cells(1, "A"), _
Cells(a, "A") _
))
MsgBox isum
End Sub

HTH
--
AP

"Harjinder Singh" a écrit dans le message de
...


Hi,

I am trying to sum of few cell wherein i am not sure what would be the
maximum cell.

for example if i am using the below given formula it givs me the some of
cell one to cell four but i do not want the static result.
"=SUM(RC[1]:RC[4])"

will it possible if I assign a value to a variable:

like

a=20
and use the formula like this:

"=SUM(RC[1]:RC[a])"

- Harry

*** Sent via Developersdex http://www.developersdex.com ***