I have 35 to 40 worksheets with daily stock data and I am trying to calculate the stock returns for each worksheet in a macro. The formula is: LN(Today/Yesterday) which gives the daily stock return. I am running the code below but I cannot figure out how to start the loop in the 5th worksheet. My portfolio is in the first four worksheets. Anyone know how this would work?
Sub Macro2()
Dim wb As Workbook
Dim i As Integer
Dim ws As Worksheet
Set wb = ActiveWorkbook
Set ws = Worksheets.Count = 5
For i = 5 To ThisWorkbook.Worksheets.Count
Activeworksheet.Columns("c").ClearContents
Range("C4").Select
ActiveCell.FormulaR1C1 = "=LN(RC[-1]/R[-1]C[-1])"
Range("C4").Select
Selection.AutoFill Destination:=Range("C4:C507")
Range("C4:C507").Select
Next i
End Sub