Results 1 to 5 of 5

Thread: Variable in a VBA macro

  1. #1
    Join Date
    May 2009
    Posts
    79
    Rep Power
    4

    Default Variable in a VBA macro

    Hello to all!
    I mexcuse in advance if this subject already exists (as nouvo this forum .....).

    Here is my concern.
    I sui Newb prog in VBA and I n'arive not implemented a code marcro my VBA code.
    Here is my snippet:

    place = 5
    LINE = 2

    Do Until Sheets ( "DB"). Cells (LINE, 1) = ""
    Sheets ( "tb_de_calcul"). Cells (7, up) = Sheets ( "DB"). Cells (LINE 2) & "" & Sheets ( "DB"). Cells (LINE 3)

    Cells (30, up) = "= AVERAGE (& Cells (11, place): Cells (22, place))"
    LINE = LINE + 1
    place = place + 1
    Loop

    My problem is on the line
    Cells (30, up) = "= AVERAGE (& Cells (11, place): Cells (22, place))"

    I would make the average of several cells for each column but can not integrate my variable place .......

    I guess I go for a v naz save me but its good life if you help me.

    Thank you in advance

  2. #2
    Join Date
    May 2009
    Posts
    86
    Rep Power
    4

    Default

    When programming in Visual Basic, we use only rarely forms (the "=....") in cells.

    This can be done, however, for example to the average Celulle A1 to A5 in cell A6:

    Code:
    Range ( "A6"). Formula = "= AVERAGE (A1: A5)" 
    Range ( "A6"). Calculate
    See also FormulaR1C1, etc..

  3. #3
    Join Date
    May 2009
    Posts
    79
    Rep Power
    4

    Default

    Thank you for your answer but what I would use my variable is "up" to vary my columns.
    Is this possible?

  4. #4
    Fidel Fleming is offline Member
    Join Date
    May 2009
    Posts
    86
    Rep Power
    4

    Default

    Yes, it is possible FormulaR1C1, and good use of quotes and &.

  5. #5
    Join Date
    May 2009
    Posts
    79
    Rep Power
    4

    Default

    I am very thankful to you.

Similar Threads

  1. Tuple variable in SQL
    By GonzalezBrown in forum Programming
    Replies: 1
    Last Post: 04-21-2010, 01:41 PM
  2. How to Extract variable "file" and "path" of a variable
    By Halle Berry in forum Software Jargons
    Replies: 1
    Last Post: 10-20-2009, 10:55 AM
  3. What's with all these variable types?
    By Kaiven Boycott in forum Programming
    Replies: 0
    Last Post: 09-30-2009, 12:42 PM
  4. Where are the different c program variable allocated in the memory
    By Jarrius Arundel in forum Everything Else
    Replies: 5
    Last Post: 07-22-2009, 08:06 AM
  5. The 'variable'
    By quckhil in forum Programming
    Replies: 0
    Last Post: 08-22-2008, 09:20 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48