View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Simple VBA Accumulator (Function?)

Does this simple macro help. If not, details.

Sub addto()
var1 = 2
var2 = 3
MsgBox var1 + var2 '5
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

wrote in message
...
Can a function get repeated values, add them, and return a total to
the calling procedure?
I need to reuse this code with differing numbers of items.

Example

Pass these parameters

add_to(1)
add_to(2)

Get the returned total from function

function accum(number)
total = total + number

RETURN TOTAL to Procedure