I'm trying to write a macro that inserts formulas into columns B-F in all worksheets in a workbook. For some reason the workbook loop isn't working and the macro just continuously runs in the first workbook. Anyone have any ideas?
Option Explicit
Sub Formuoli()
Dim iLastRow As Integer
Dim i As Integer
Dim ws As Worksheet
iLastRow = Range("a10000").End(xlUp).Row
For Each ws In ThisWorkbook.Worksheets
With ws
For i = 1 To iLastRow
Range("B" & i).Select
Selection.Formula = 'these are formulas
Range("C" & i).Select
Selection.Formula = 'these are formulas
Range("D" & i).Select
Selection.Formula = 'these are formulas
Range("E" & i).Select
Selection.Formula = 'these are formulas
Range("F" & i).Select
Selection.Formula = 'these are formulas
Next i
End With
Next ws
End Sub