Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel cell reference
Message
De
21/06/2007 11:59:16
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
21/06/2007 11:14:04
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01230317
Message ID:
01234763
Vues:
11
This message has been marked as the solution to the initial question of the thread.
>I'm still trying to get a grip on your technique. Suppose you captured a cell reference as in
>
>cell1 = .activecell
>
>then moved the cursor somewhere else and
>
>cell2 = .activecell
>
>Cell1 and cell2 now define the boundries of a range. How would you specify the sum of that range?
>
>* move again and . . .
>.selection.value = '=sum(' + cell1 ':' cell2 + ')'    && this is the idea
>
1. To insert a formula, you don't use .Value, but .FormulaR1C1. (Try saving a macro, and look at the results.)
2. This formula expects a text, not a range object.

For example, if I save a macro and create a sum for the 3 cells above, I get:
ActiveCell.FormulaR1C1 = "=SUM(R[-3]C:R[-1]C)"
Considering that the number of rows might vary, I might change this to:
loSheet.Cells(lnRow, xlCol_F).FormulaR1C1 = "=SUM(R[-" + transform(lnNumRows);
  + "]C:R[-1]C)"
Where:
  • loSheet is an object reference to an Excel sheet
  • xlCol_F is defined as: #DEFINE xlCol_F 6
  • lnNumRows contains the number of rows I need to add. In practice, I usually use some other expression in this case.

    HTH,

    Hilmar.
    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
    Suivant
    Répondre
    Fil
    Voir

    Click here to load this message in the networking platform