+ Reply to Thread
Results 1 to 2 of 2

formula R1C1 vs variable

Hybrid View

  1. #1
    Registered User
    Join Date
    03-16-2009
    Location
    italy
    MS-Off Ver
    Excel 2003
    Posts
    64

    formula R1C1 vs variable

    i've been trying to modify Macro5() to Macro6()
    but it doesn't work, can help , thanks

    Sub Macro5()
    
        Range("J5151").Select
        ActiveCell.FormulaR1C1 = _
            "=TREND(R[-365]C[5]:R[-152]C[5],R[-365]C[-8]:R[-152]C[-8],RC[-8])"
    End Sub

    Sub Macro6()
    
    Dim row1 As Long
    Dim row2 As Long
    Dim row3 As Long
    Dim col1 As Long
    Dim col2 As Long
    
    
        Range("J5151").Select
        ActiveCell.FormulaR1C1 = _
            "=TREND(cells(row1,col1):cells(row2,col1),cells(row1,col2):cells(row2,col2),cells(row3,col2))"
    End Sub

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,980

    Re: formula R1C1 vs variable

    You haven't given the variables any values and you can't use the Cells(row, column) syntax within a formula string. It would need to be something like:
    ActiveCell.FormulaR1C1 = _
            "=TREND(R" & row1 & "C" & col1 & ":R" & row2 & "C" & col1 & ",R" & row1 & "C" & col2 & ":R" & row2 & "C" & col2 & ",R" & row3 & "C" & col2 & ")"
    Everyone who confuses correlation and causation ends up dead.

+ 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