To make a variable available to all procedures in all the vba modules
in a project, declare the variable at module level by using the Public
keyword rather than Dim AND putting it before the first procedure in
a standard vba module. Eg:
Public myVariable as long
Re:"How would I put into the cell A11 the formula = sum(A1:A10) using
VBA code?"
If you record a macro you'll get R1C1 type references which you can
adjust thus:
Worksheets("Sheet1").Range("A11").FormulaR1C1 = "=SUM(R[-10]C:R[-1]C)"
Easier to write and understand though, you could use A1 type refs:
Worksheets("Sheet1").Range("A11").Formula = "=SUM(A1:A10)"