+ Reply to Thread
Results 1 to 2 of 2

using variables in a range of formular

  1. #1
    Registered User
    Join Date
    01-29-2007
    Posts
    1

    using variables in a range of formular

    someone know how to include a variable in a formular using macro?

    eg.
    Dim a As Double
    range("a1").select
    ActiveCell.FormulaR1C1 = "=Linest(range(cells(2,4),cells(a,4)),range(cells(2,5),cells(a,5)),true,true)"

    this is not working and displayed the whole formular as a string.

    any hlep will be very very appreciated.
    Last edited by lin-jin; 01-29-2007 at 02:42 PM.

  2. #2
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by lin-jin
    someone know how to include a variable in a formular using macro?

    eg.
    Dim a As Double
    range("a1").select
    ActiveCell.FormulaR1C1 = "=Linest(range(cells(2,4),cells(a,4)),range(cells(2,5),cells(a,5)),true,true)"

    this is not working and displayed the whole formular as a string.

    any hlep will be very very appreciated.
    Hi,

    the formula you are using appears incorrect, the closest I could come to a translation was

    ActiveCell.Formula = "=LINEST(A4:B4,A5:B5,TRUE,TRUE)"

    if you want this to be 'row' variable , then

    dim iRow as long
    iRow = 4
    ActiveCell.Formula = "=LINEST(A" & iRow & ":B" & iRow & ",A" & iRow +1 & ":B" & iRow +1 & ",TRUE,TRUE)"

    hth
    ---
    Si fractum non sit, noli id reficere.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1