Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel insert a sum function in code
Message
De
17/03/2008 22:24:51
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01302702
Message ID:
01302873
Vues:
10
>Does anyone have an example how to insert sum() function in excel spreadsheet in code? I'm building the spreadsheet in code, and at the end, I want to sum each column.

You can get the syntax for almost any Excel command with the Record Macro feature. Record the macro, and then look at the generated code. See also my introduction to Excel Automation - Universal Thread Magazine, September 2002.

In the case of the sum, this gives you a syntax in row/column format, which is a little different from the one Sergey suggested. I got accustomed to this syntax, and prefer it, because both rows and columns are referred to by numbers, which is easier (in the case of columns) than letters. (What is the next column after column AC? After column AZ? Easy for a human, but tricky to program.)

The main problem with the sum is usually to get the number of rows, which is often variable.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform