Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel cell reference
Message
De
21/06/2007 16:12:14
 
 
À
21/06/2007 11:59:16
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01230317
Message ID:
01234881
Vues:
11
>>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.

    Hilmar -

    Thanks, that gets me there.
  • Précédent
    Répondre
    Fil
    Voir

    Click here to load this message in the networking platform