loop trend formula

montecarlo2012

Well-known Member
Joined
Jan 26, 2011
Messages
984
Office Version
  1. 2010
Platform
  1. Windows
Hi, I am trying to loop the trend formula in my array A1:F21 and go every four rows on the first col, next col etc. and the results on col I, the code I write have something wrong. any advise please.
Code:
Option Explicit
Sub subtractone()
Dim i As Integer, j As Integer

   For j = 2 To 7
    For i = 2 To Cells(Rows.Count, "a").End(xlUp).Row - 1
    
        Cells(i, 7 + j) = "= trend(Cells(i, j))"
        
        
Next
Next

End Sub
the array is integers , thanks.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Can you post an example of what the formulas should be, and where they should appear?
 
Upvote 0
thanks, shg, maybe the macro illustrated better?,
Code:
Sub trend()
' trend Macro
 Range("H1").Select
    ActiveCell.FormulaR1C1 = "=TREND(RC[-7]:R[3]C[-7])"
    Range("H1").Select
    Selection.AutoFill Destination:=Range("H1:H6"), Type:=xlFillDefault
    Range("H1:H6").Select
    Selection.AutoFill Destination:=Range("H1:M6"), Type:=xlFillDefault
    Range("H1:M6").Select
End Sub
 
Upvote 0
Maybe ...

Code:
Sub Trend()
  Range("H1", Cells(Cells(Rows.Count, "A").End(xlUp).Row, "H")).FormulaR1C1 = "=TREND(RC[-7]:R[3]C[-7])"
End Sub

I have no idea what this means:

and go every four rows on the first col, next col etc.
 
Upvote 0
Glad it did, you're welcome.
 
Upvote 0

Forum statistics

Threads
1,215,779
Messages
6,126,842
Members
449,343
Latest member
DEWS2031

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top